1

I have followed this answer: https://serverfault.com/a/893075/210494. I have CentOS 7.8.

redis.service

[Service]
Type=notify
ExecStart=/opt/redis/bin/redis-server /opt/redis/conf/redis-master.conf
TimeoutStartSec=60
TimeoutStopSec=60
TimeOutSec=90
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

If I comment out Type=notify, then systemctl finishes immediatelly but this is in the logs.

68629:C 28 Aug 2020 17:29:58.933 # Redis version=6.0.6, bits=64, commit=00000000, modified=0, pid=68629, just started
68629:C 28 Aug 2020 17:29:58.933 # Configuration loaded
68629:C 28 Aug 2020 17:29:58.933 # WARNING supervised by systemd - you MUST set appropriate values for TimeoutStartSec and TimeoutStopSec in your service unit.
68629:C 28 Aug 2020 17:29:58.933 # systemd supervision requested, but NOTIFY_SOCKET not found
68629:M 28 Aug 2020 17:29:58.933 * Increased maximum number of open files to 4096 (it was originally set to 1024).
68629:M 28 Aug 2020 17:29:58.934 * Running mode=standalone, port=6380.
68629:M 28 Aug 2020 17:29:58.934 # Server initialized

Where is the problem? I found DigitalOcean tutorial where they do not have Type=notify and I found Redis issues when they successfully recommended Type=notify.

Update

Job for redis.service failed because a timeout was exceeded. See "systemctl status redis.service" and "journalctl -xe" for details.
[root@DB dev]# systemctl status redis
● redis.service - Redis
   Loaded: loaded (/etc/systemd/system/redis.service; enabled; vendor preset: disabled)
   Active: failed (Result: timeout) since Sun 2020-08-30 12:06:58 CEST; 46min ago
  Process: 11134 ExecStart=/opt/app/redis/default/bin/redis-server /opt/app/redis/default/conf/redis-master.conf (code=exited, status=0/SUCCESS)
 Main PID: 11134 (code=exited, status=0/SUCCESS)
Aug 30 12:05:57 DB systemd[1]: Starting Redis...
Aug 30 12:06:58 DB systemd[1]: redis.service start operation timed out. Terminating.
Aug 30 12:06:58 DB systemd[1]: Failed to start Redis.
Aug 30 12:06:58 DB systemd[1]: Unit redis.service entered failed state.
Aug 30 12:06:58 DB systemd[1]: redis.service failed.
  • Well, that isn't making the slightest bit of sense. Check the journal and dmesg to see if there's anything else unusual going on. – Michael Hampton Aug 30 at 16:19
  • It would have been helpful to mention that you compiled redis yourself. Nobody would generally expect anyone to do that for a production system. – Michael Hampton Aug 31 at 13:03
  • What? Redis does not provide binaries, does it? redis.io/download – Leos Literak Aug 31 at 13:25
  • If you used a binary then it would have been helpful to mention that too. This also is something that would be unexpected. – Michael Hampton Aug 31 at 13:26
  • Though, now that I think about it more, redis official binaries not compiled with systemd support, and not throwing an error when you try to use systemd, is a really bad thing. I suggest filing a bug report. – Michael Hampton Aug 31 at 13:33
2

Ok, the problem was that systemd support is not compiled by default. You need to compile it explicitelly. I will write a PR to update README.md in sources because this is not explained.

This commit is responsible for this behaviour. I found it in this issue: https://github.com/redis/redis/issues/7217

yum install systemd-devel
make BUILD_WITH_SYSTEMD=yes USE_SYSTEMD=yes
| improve this answer | |
  • 1
    Thanks for this. Been debugging this for two hours! – Andy Oct 16 at 13:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.