nghttpx: Save PID file after it is ready to accept connections

This commit is contained in:
Tatsuhiro Tsujikawa 2016-05-21 10:42:09 +09:00
parent c39a669671
commit 9f770fec36
1 changed files with 8 additions and 4 deletions

View File

@ -946,10 +946,6 @@ int event_loop() {
redirect_stderr_to_errorlog();
}
if (!get_config()->pid_file.empty()) {
save_pid();
}
SignalServer ssv;
rv = pipe(ssv.ipc_fd.data());
@ -996,6 +992,14 @@ int event_loop() {
worker_process_childev.data = nullptr;
ev_child_start(loop, &worker_process_childev);
// Write PID file when we are ready to accept connection from peer.
// This makes easier to write restart script for nghttpx. Because
// when we know that PID file is recreated, it means we can send
// QUIT signal to the old process to make it shutdown gracefully.
if (!get_config()->pid_file.empty()) {
save_pid();
}
ev_run(loop, 0);
return 0;