Describe the bug
If you setup Redis with systemd but you use a binary that was not compiled with systemd support, there is no clear error in the log. Info command does not show if the systemd support was compiled or not. I would prefer that Redis would log an error that the systemd support must be compiled if you use supervised systemd.
https://serverfault.com/questions/1031891/redis-service-hangs-with-systemctl-and-type-notify
To reproduce
Compile Redis without systemd support.
redis.service
[Service]
Type=notify
ExecStart=/opt/redis/bin/redis-server /opt/redis/conf/redis-master.conf
TimeoutStartSec=60
TimeoutStopSec=60
RestartSec=5s
Restart=on-success
redis-master.conf
daemonize no
supervised systemd
When I run this service, the Redis process starts but the systemctl hangs and I have to press Ctrl-C to get back to shell. This is in the logs:
69486:C 28 Aug 2020 17:31:14.545 # Redis version=6.0.6, bits=64, commit=00000000, modified=0, pid=69486, just started
69486:C 28 Aug 2020 17:31:14.545 # Configuration loaded
69486:C 28 Aug 2020 17:31:14.545 # WARNING supervised by systemd - you MUST set appropriate values for TimeoutStartSec and TimeoutStopSec in your service unit.
69486:M 28 Aug 2020 17:31:14.546 * Increased maximum number of open files to 4096 (it was originally set to 1024).
69486:M 28 Aug 2020 17:31:14.547 * Running mode=standalone, port=6380.
69486:M 28 Aug 2020 17:31:14.547 # Server initialized
Expected behavior
Redis shall log that supervised systemd requires libsystemd support to be compiled in.
Additional information
Any additional information that is relevant to the problem.
Comment From: oranagra
@literakl i suppose you want redis to exit too, not just log it, right?
care to test this patch for me, or provide a PR?
server.supervised = redisIsSupervised(server.supervised_mode);
+#ifndef HAVE_LIBSYSTEMD
+ if (server.supervised_mode == SUPERVISED_SYSTEMD) {
+ serverLog(LL_WARNING, "Redis is configured to use systemd supervision but it was not built with support for it.");
+ exit(1);
+ }
+#endif
int background = server.daemonize && !server.supervised;
if (background) daemonize();
Comment From: literakl
I will test it tomorrow. Thanks
st 2. 9. 2020 v 14:44 odesílatel Oran Agra notifications@github.com napsal:
@literakl https://github.com/literakl i suppose you want redis to exit too, not just log it, right?
care to test this patch for me, or provide a PR?
server.supervised = redisIsSupervised(server.supervised_mode);+#ifndef HAVE_LIBSYSTEMD+ if (server.supervised_mode == SUPERVISED_SYSTEMD) {+ serverLog(LL_WARNING, "Redis is configured to use systemd supervision but it was not built with support for it.");+ exit(1);+ }+#endif int background = server.daemonize && !server.supervised; if (background) daemonize();— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/redis/redis/issues/7735#issuecomment-685710068, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABQWNN5SWOAYD3YNIQJGPMLSDY44PANCNFSM4QRK2E4Q .
Comment From: literakl
This should be when compiled with default params (no systemd)
7443:C 03 Sep 2020 14:02:23.213 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo 7443:C 03 Sep 2020 14:02:23.213 # Redis version=6.0.6, bits=64, commit=00000000, modified=0, pid=7443, just started 7443:C 03 Sep 2020 14:02:23.213 # Configuration loaded 7443:C 03 Sep 2020 14:02:23.213 # WARNING supervised by systemd - you MUST set appropriate values for TimeoutStartSec and TimeoutStopSec in your service unit. 7443:M 03 Sep 2020 14:02:23.214 # You requested maxclients of 10000 requiring at least 10032 max file descriptors. 7443:M 03 Sep 2020 14:02:23.214 # Server can't set maximum open files to 10032 because of OS error: Operation not permitted. 7443:M 03 Sep 2020 14:02:23.214 # Current maximum open files is 4096. maxclients has been reduced to 4064 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'. 7443:M 03 Sep 2020 14:02:23.215 * Running mode=standalone, port=6379. 7443:M 03 Sep 2020 14:02:23.215 # Server initialized 7443:M 03 Sep 2020 14:02:23.215 * Loading RDB produced by version 6.0.6 7443:M 03 Sep 2020 14:02:23.215 * RDB age 228 seconds 7443:M 03 Sep 2020 14:02:23.215 * RDB memory usage when created 0.50 Mb 7443:M 03 Sep 2020 14:02:23.215 * DB loaded from disk: 0.000 seconds 7443:M 03 Sep 2020 14:02:23.215 * Ready to accept connections 7443:signal-handler (1599134554) Received SIGTERM scheduling shutdown... 7443:M 03 Sep 2020 14:02:34.143 # User requested shutdown... 7443:M 03 Sep 2020 14:02:34.143 * Saving the final RDB snapshot before exiting. 7443:M 03 Sep 2020 14:02:34.148 * DB saved on disk 7443:M 03 Sep 2020 14:02:34.148 # Redis is now ready to exit, bye bye...
server.c
server.supervised = redisIsSupervised(server.supervised_mode);
#ifndef HAVE_LIBSYSTEMD
if (server.supervised_mode == SUPERVISED_SYSTEMD) {
serverLog(LL_WARNING, "Redis is configured to use systemd supervision but it was not built with support for it.");
exit(1);
}
#endif
Comment From: yossigo
Fixed by #8036