redis: build with USE_SYSTEMD=yes when systemd is enabled

Compile redis with full systemd support when the chosen init system is
systemd.

Enabling systemd supervision allows redis to communicate the actual server
status (i.e. "Loading dataset", "Waiting for master<->replica sync") to
systemd, instead of declaring readiness right after initializing the server
process.

Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
This commit is contained in:
Ovidiu Panait 2022-09-23 13:06:03 +03:00 committed by Khem Raj
parent ce62753e9e
commit fd4ae00b2b
2 changed files with 7 additions and 2 deletions

View File

@ -9,6 +9,7 @@ ExecStart=/usr/bin/redis-server /etc/redis/redis.conf
ExecStop=/usr/bin/redis-cli shutdown
Restart=always
LimitNOFILE=10032
Type=notify
[Install]
WantedBy=multi-user.target

View File

@ -35,7 +35,10 @@ USERADD_PACKAGES = "${PN}"
USERADD_PARAM:${PN} = "--system --home-dir /var/lib/redis -g redis --shell /bin/false redis"
GROUPADD_PARAM:${PN} = "--system redis"
REDIS_ON_SYSTEMD = "${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}"
PACKAGECONFIG = "${@bb.utils.filter('DISTRO_FEATURES', 'systemd', d)}"
PACKAGECONFIG[systemd] = "USE_SYSTEMD=yes,USE_SYSTEMD=no,systemd"
EXTRA_OEMAKE += "${PACKAGECONFIG_CONFARGS}"
do_compile:prepend() {
(cd deps && oe_runmake hiredis lua linenoise)
@ -55,8 +58,9 @@ do_install() {
install -m 0644 ${WORKDIR}/redis.service ${D}${systemd_system_unitdir}
sed -i 's!/usr/sbin/!${sbindir}/!g' ${D}${systemd_system_unitdir}/redis.service
if [ "${REDIS_ON_SYSTEMD}" = true ]; then
if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
sed -i 's!daemonize yes!# daemonize yes!' ${D}/${sysconfdir}/redis/redis.conf
sed -i 's!supervised no!supervised systemd!' ${D}/${sysconfdir}/redis/redis.conf
fi
}