Create PID file even if in foreground
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
This commit is contained in:
parent
3c7daa5bec
commit
fb538fb98e
@ -2374,7 +2374,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);
|
||||
}
|
||||
@ -3759,9 +3759,10 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
|
||||
server.supervised = redisIsSupervised();
|
||||
if (server.daemonize && server.supervised == 0) daemonize();
|
||||
int background = server.daemonize && server.supervised == 0;
|
||||
if (background) daemonize();
|
||||
initServer();
|
||||
if (server.daemonize && server.supervised == 0) createPidFile();
|
||||
if (background || server.pidfile) createPidFile();
|
||||
redisSetProcTitle(argv[0]);
|
||||
redisAsciiArt();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user