Skip to content

Commit

Permalink
Create PID file even if in foreground
Browse files Browse the repository at this point in the history
Previously, Redis only wrote the pid file if
it was daemonizing, but many times it's useful to have
the pid written out even if you're in the foreground.

Some background for this is:
I usually run redis via daemontools. That entails running
redis-server on the foreground. Given that, I'd also want
redis-server to create a pidfile so other processes (e.g. nagios)
can run checks for that.

Closes #463
  • Loading branch information
rebx authored and mattsta committed Aug 2, 2014
1 parent 27a9dbd commit 4a799b6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/redis.c
Expand Up @@ -2331,7 +2331,7 @@ int prepareForShutdown(int flags) {
return REDIS_ERR;
}
}
if (server.daemonize) {
if (server.daemonize || server.pidfile) {
redisLog(REDIS_NOTICE,"Removing the pid file.");
unlink(server.pidfile);
}
Expand Down Expand Up @@ -3571,7 +3571,7 @@ int main(int argc, char **argv) {
}
if (server.daemonize) daemonize();
initServer();
if (server.daemonize) createPidFile();
if (server.daemonize || server.pidfile) createPidFile();
redisSetProcTitle(argv[0]);
redisAsciiArt();

Expand Down

0 comments on commit 4a799b6

Please sign in to comment.