-
-
Save geschke/ab6afa91b2d9dfcd5c25 to your computer and use it in GitHub Desktop.
[Unit] | |
Description=Redis Datastore Server | |
After=network.target | |
[Service] | |
Type=forking | |
PIDFile=/var/run/redis/redis.pid | |
ExecStartPre=/bin/mkdir -p /var/run/redis | |
ExecStartPre=/bin/chown redis:redis /var/run/redis | |
ExecStart=/sbin/start-stop-daemon --start --chuid redis:redis --pidfile /var/run/redis/redis.pid --umask 007 --exec /usr/bin/redis-server -- /etc/redis/redis.conf | |
ExecReload=/bin/kill -USR2 $MAINPID | |
[Install] | |
WantedBy=multi-user.target |
Just wanted to add that Redis server parameters, such as daemonize no
, can be passed as CLI arguments --daemonize no
.
Having all the settings in the service declaration file releases from maintaining consistency across multiple config files.
See the example: Gist.
What configuration should I add in the [Unit] section to make the service-disabled by default. Or any other options to make this by code will be really helpful
Just a remark: The original gist is really, really old. Ubuntu has reached the 20.10 version, so today these hints are outdated.
If you want to handle a systemd service, read the instructions for systemctl. To disable a service, a command like
"sudo systemctl disable " will be used.
And/or use Google to search for recent documentation, there are plenty of websites which describe systemd/systemctl, e.g. here: https://linoxide.com/linux-how-to/enable-disable-services-ubuntu-systemd-upstart/
Thanks & Kind regards
Just to toss my hat in this ring, this is the unit file that ended up working for me. I'm using a self-compiled Redis,
v=4.0.6 sha=00000000:0 malloc=jemalloc-4.0.3 bits=64 build=f5447a0fadf7b78a
running on Ubuntu 16.04:You have to edit
/etc/redis/redis.conf
to include these lines: