Skip to content

Instantly share code, notes, and snippets.

@sshymko
Last active May 8, 2024 14:56
Show Gist options
  • Save sshymko/898aee7d0ec0e3d2a8a41f0956756530 to your computer and use it in GitHub Desktop.
Save sshymko/898aee7d0ec0e3d2a8a41f0956756530 to your computer and use it in GitHub Desktop.
Redis service for systemd on Linux
[Unit]
Description=Redis persistent key-value storage
After=network.target
[Service]
Type=notify
ExecStart=/usr/bin/redis-server /etc/redis.conf --supervised systemd --daemonize no
ExecStop=/usr/bin/redis-cli -p 6379 shutdown
ExecReload=/bin/kill -USR2 $MAINPID
Restart=always
[Install]
WantedBy=multi-user.target
@sshymko
Copy link
Author

sshymko commented Nov 8, 2020

@willzhang
Mode --supervised systemd requires --daemonize no. Otherwise, it should be turned on.

@crussell52
Copy link

The ExecStop value is problematic if there is auth set. It seems to work fine without it because systemd will just send a SIGTERM to the process.

@sshymko
Copy link
Author

sshymko commented Oct 14, 2021

@crussell52 is there a better way to handle ExecStop to account for both auth and non-auth cases?

@crussell52
Copy link

crussell52 commented Oct 15, 2021 via email

@sshymko
Copy link
Author

sshymko commented Oct 15, 2021

@crussell52
The reason to include ExecStop was to distinguish Redis instances running on different ports.
But looks like you're right, omitting the stop command will work in this case as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment