Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CentOs 7: Systemd & PID File #3716

Closed
ghost opened this Issue Dec 29, 2016 · 2 comments

Comments

Projects
None yet
1 participant
@ghost
Copy link

ghost commented Dec 29, 2016

I am using the redis 2.8.19 version from the EPEL repository and CentOs 7.3

Redis server v=2.8.19 sha=00000000:0 malloc=jemalloc-3.6.0 bits=64 build=c0359e7aa3798aa2

I installed it with yum:
$ sudo yum install redis -y

I need the PID file to add to as a service for monit.

This is my /etc/redis.conf config file:

daemonize yes
pidfile /var/run/redis/redis.pid

And i edited the next file:

$ sudo nano /usr/lib/systemd/system/redis.service
ExecStart=/usr/bin/redis-server /etc/redis.conf --daemonize yes

Then:

sudo systemctl daemon-reload
sudo systemctl start redis
sudo systemctl enable redis

But the PID does not exists and the status of the redis service is:

● redis.service - Redis persistent key-value database
   Loaded: loaded (/usr/lib/systemd/system/redis.service; enabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/redis.service.d
           └─limit.conf
   Active: inactive (dead) since Thu 2016-12-29 10:41:34 CST; 9s ago
 Main PID: 3207 (code=exited, status=0/SUCCESS)

Dec 29 10:41:34 host.local systemd[1]: Started Redis persistent key-value database.
Dec 29 10:41:34 host.local systemd[1]: Starting Redis persistent key-value database...

The /var/run/redis directory has the correct permissions:
drwxr-xr-x. 2 redis redis 40 Dec 29 10:41 redis

I followed the next Issues:

When damonize=no is set, redis-server never writes a PID file
#2076

Always pidfile if defined
#1967

But the bug is not fixed.

@badboy

This comment has been minimized.

Copy link
Contributor

badboy commented Dec 30, 2016

If you set daemonize = yes you need to set Type = forking in your systemd service file.
If you set daemonize = no you can add a ExecStartPost=/bin/sh -c "echo $MAINPID > /run/redis.pid line to your service file to let systemd write the pid file.

@ghost

This comment has been minimized.

Copy link
Author

ghost commented Jan 3, 2017

Thanks @badboy , i added to the file:

/usr/lib/systemd/system/redis.service

The next line:

ExecStartPost=/bin/sh -c "echo $MAINPID > /var/run/redis/redis.pid"

And the pid number is correctly written in the file!

@ghost ghost closed this Jan 3, 2017

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.