You are not logged in.

#1 2012-02-16 19:18:56

uberscientist
Member
Registered: 2012-01-27
Posts: 84

redis and systemd

I recently installed MySQL and the wiki had good instructions on how to daemonize it on startup with systemd and I am about to try to figure how to do the same for the redis-server.

If anyone has tips for me, or anything else: Please let me know here, otherwise I'll keep editing this with updates on my progress.

I'm also interested in starting a wiki article talking about redis on arch, or just prodding someone with more experience to do so smile

-Edit:

Ok using the mysql.service here's the systemd service file for redis:
/lib/systemd/system/redis.service
----------------------------

[Unit]
Description=Redis Server
After=network.target

[Service]
Type=simple
ExecStart=/usr/bin/redis-server /etc/redis.conf
ExecStop=/bin/kill -15 $MAINPID
PIDFile=/var/run/redis.pid
Restart=always

[Install]
WantedBy=multi-user.target

systemctl enable redis.service

Last edited by uberscientist (2012-02-16 20:05:27)

Offline

#2 2012-08-30 05:25:26

three.onefour
Member
Registered: 2012-08-30
Posts: 1

Re: redis and systemd

Thanks for this. A few things:

To get the command "redis-server /etc/redis.conf" to work, I had to "sudo mkdir /var/lib/redis". Presumably the default redis.conf makes use of that directory. I also had to set a couple permissions on the log file specified by the default redis.conf:

sudo chgrp log /var/log/redis.log
sudo chmod 664 /var/log/redis.log

After that redis-server /etc/redis.conf will go off without a hitch.

However, running this from systemctl still isn't working for me - the process starts fine, but then something shuts it down right after startup:

[1912] 30 Aug 13:12:08 * Server started, Redis version 2.4.16
[1912] 30 Aug 13:12:08 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
[1912] 30 Aug 13:12:08 * DB loaded from disk: 0 seconds
[1912] 30 Aug 13:12:08 * The server is now ready to accept connections on port 6379
[1912] 30 Aug 13:12:08 - 0 clients connected (0 slaves), 717576 bytes in use
[1912] 30 Aug 13:12:08 # Received SIGTERM, scheduling shutdown...
[1912] 30 Aug 13:12:08 # User requested shutdown...
[1912] 30 Aug 13:12:08 * Saving the final RDB snapshot before exiting.
[1912] 30 Aug 13:12:08 * DB saved on disk
[1912] 30 Aug 13:12:08 * Removing the pid file.
[1912] 30 Aug 13:12:08 # Redis is now ready to exit, bye bye...

Any idea what could be going on?

Offline

#3 2012-09-15 20:04:18

Lomig
Member
Registered: 2009-04-07
Posts: 2

Re: redis and systemd

three.onefour wrote:

However, running this from systemctl still isn't working for me - the process starts fine, but then something shuts it down right after startup:

[1912] 30 Aug 13:12:08 * Server started, Redis version 2.4.16
[1912] 30 Aug 13:12:08 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
[1912] 30 Aug 13:12:08 * DB loaded from disk: 0 seconds
[1912] 30 Aug 13:12:08 * The server is now ready to accept connections on port 6379
[1912] 30 Aug 13:12:08 - 0 clients connected (0 slaves), 717576 bytes in use
[1912] 30 Aug 13:12:08 # Received SIGTERM, scheduling shutdown...
[1912] 30 Aug 13:12:08 # User requested shutdown...
[1912] 30 Aug 13:12:08 * Saving the final RDB snapshot before exiting.
[1912] 30 Aug 13:12:08 * DB saved on disk
[1912] 30 Aug 13:12:08 * Removing the pid file.
[1912] 30 Aug 13:12:08 # Redis is now ready to exit, bye bye...

Any idea what could be going on?

Systemd take in charge the "daemonzing" of your daemons where rc.d was a bunch of scripts needing such a parameter. You have to comment

daemonize yes

in your /etc/redis.conf file.

Hope it helps smile

Offline

Board footer

Powered by FluxBB