Fix log printing always shows the role as child under daemonize (#1301)
In #1282, we init server.pid earlier to keep log message role consistent, but we forgot to consider daemonize. In daemonize mode, we will always print the child role. We need to reset server.pid after daemonize(), otherwise the log printing role will always be the child. It also causes a incorrect server.pid value, affecting the concatenation of some pid names. Signed-off-by: Binbin <binloveplay1314@qq.com>
This commit is contained in:
parent
2df56d87c0
commit
6fba747c39
@ -7064,7 +7064,12 @@ __attribute__((weak)) int main(int argc, char **argv) {
|
||||
/* Daemonize if needed */
|
||||
server.supervised = serverIsSupervised(server.supervised_mode);
|
||||
int background = server.daemonize && !server.supervised;
|
||||
if (background) daemonize();
|
||||
if (background) {
|
||||
/* We need to reset server.pid after daemonize(), otherwise the
|
||||
* log printing role will always be the child. */
|
||||
daemonize();
|
||||
server.pid = getpid();
|
||||
}
|
||||
|
||||
serverLog(LL_NOTICE, "oO0OoO0OoO0Oo Valkey is starting oO0OoO0OoO0Oo");
|
||||
serverLog(LL_NOTICE, "Valkey version=%s, bits=%d, commit=%s, modified=%d, pid=%d, just started", VALKEY_VERSION,
|
||||
|
Loading…
x
Reference in New Issue
Block a user