package/redis: add optional support for systemd
authorTitouan Christophe <titouan.christophe@railnova.eu>
Tue, 2 Jun 2020 10:40:11 +0000 (12:40 +0200)
committerYann E. MORIN <yann.morin.1998@free.fr>
Fri, 5 Jun 2020 22:28:46 +0000 (00:28 +0200)
- Use the unit type=notify (Redis contacts systemd when ready)
- Start redis with the supervised option, so it knows it should
  talk to systemd
- USE_SYSTEMD is not documented, but it is used in the src/Makefile

Signed-off-by: Titouan Christophe <titouan.christophe@railnova.eu>
[yann.morin.1998@free.fr: add and explain USE_SYSTEMD]
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
package/redis/redis.mk
package/redis/redis.service

index ae823429b3cb7ade78d3e1275e6f0e1e002246bf..262f6cd1f41ae1edc06b041b4bb208dd85936526 100644 (file)
@@ -30,6 +30,13 @@ endif
 REDIS_BUILDOPTS = $(TARGET_CONFIGURE_OPTS) \
        PREFIX=$(TARGET_DIR)/usr MALLOC=libc
 
+ifeq ($(BR2_PACKAGE_SYSTEMD),y)
+REDIS_DEPENDENCIES += systemd
+REDIS_BUILDOPTS += USE_SYSTEMD=yes
+else
+REDIS_BUILDOPTS += USE_SYSTEMD=no
+endif
+
 ifeq ($(BR2_PACKAGE_LIBOPENSSL),y)
 REDIS_DEPENDENCIES += libopenssl
 REDIS_BUILDOPTS += BUILD_TLS=yes
index 0a8162b8ab8ec8680c08eb68b6f2a50429ecf3d7..2cc82a1980c9e3353195c3d645cbdcd55b4f45a7 100644 (file)
@@ -1,13 +1,15 @@
 [Unit]
-Description=Advanced key-value store
+Description=Redis data structure server
+Documentation=https://redis.io/documentation
 After=network.target
 
 [Service]
-Type=simple
+Type=notify
 User=redis
 Group=redis
-ExecStart=/usr/bin/redis-server /etc/redis.conf
-ExecStop=/usr/bin/redis-cli shutdown
+ExecStart=/usr/bin/redis-server --supervised systemd --daemonize no
+TimeoutStartSec=5
+TimeoutStopSec=5
 CapabilityBoundingSet=
 PrivateTmp=true
 PrivateDevices=true