Hi! How to get this going forward?
On 21/02/2018 10:45, Michael Wallner wrote: > On 21/02/18 10:29, Remi Collet wrote: >> Hi, >> >> Le 21/02/2018 à 10:21, Michael Wallner a écrit : >>> I also have a patch I'd like to discuss with the new maintainers, which >>> attempts to fix FPM's SIGUSR2 graceful restart behaviour, and which >>> we've been running for half a year now IIRC. >> >> Any link to the patch ? > > Sure, attached! > -- Regards, Mike
commit 08754dba5a87128bd7182bb2146ff64036fecaa1 Author: Michael Wallner <m...@php.net> Date: Wed Mar 15 08:43:04 2017 +0100 php-fpm: graceful restart without losing requests diff --git a/sapi/fpm/fpm/fpm_process_ctl.c b/sapi/fpm/fpm/fpm_process_ctl.c index ca5a6f2e40..72985699aa 100644 --- a/sapi/fpm/fpm/fpm_process_ctl.c +++ b/sapi/fpm/fpm/fpm_process_ctl.c @@ -80,6 +80,16 @@ static void fpm_pctl_exit() /* {{{ */ static void fpm_pctl_exec() /* {{{ */ { + switch (fork()) { + case 0: + break; + case -1: + zlog(ZLOG_SYSERROR, "failed to reload: fork() failed"); + /* no break */ + default: + fpm_global_config.pid_file = NULL; + return; + } zlog(ZLOG_NOTICE, "reloading: execvp(\"%s\", {\"%s\"" "%s%s%s" "%s%s%s" "%s%s%s" "%s%s%s" "%s%s%s" "%s%s%s" "%s%s%s" "%s%s%s" "%s%s%s" "%s%s%s" @@ -108,9 +118,8 @@ static void fpm_pctl_action_last() /* {{{ */ { switch (fpm_state) { case FPM_PCTL_STATE_RELOADING: - fpm_pctl_exec(); - break; - + zlog(ZLOG_NOTICE, "exiting after reload"); + exit(FPM_EXIT_OK); case FPM_PCTL_STATE_FINISHING: case FPM_PCTL_STATE_TERMINATING: fpm_pctl_exit(); @@ -197,6 +206,10 @@ static void fpm_pctl_action_next() /* {{{ */ fpm_pctl_kill_all(sig); fpm_signal_sent = sig; fpm_pctl_timeout_set(timeout); + + if (fpm_signal_sent == SIGQUIT && fpm_state == FPM_PCTL_STATE_RELOADING) { + fpm_pctl_exec(); + } } /* }}} */ diff --git a/sapi/fpm/fpm/fpm_sockets.c b/sapi/fpm/fpm/fpm_sockets.c index d58a8f82b6..5016914395 100644 --- a/sapi/fpm/fpm/fpm_sockets.c +++ b/sapi/fpm/fpm/fpm_sockets.c @@ -60,7 +60,17 @@ static void fpm_sockets_cleanup(int which, void *arg) /* {{{ */ if (which == FPM_CLEANUP_PARENT_EXIT_MAIN) { if (ls->type == FPM_AF_UNIX) { - unlink(ls->key); + struct sockaddr_un sa_un; + + memset(&sa_un, 0, sizeof(sa_un)); + strlcpy(sa_un.sun_path, ls->key, sizeof(sa_un.sun_path)); + sa_un.sun_family = AF_UNIX; + + if (fpm_socket_unix_test_connect(&sa_un, sizeof(sa_un)) == 0) { + zlog(ZLOG_WARNING, "Keeping unix socket, another FPM instance seems to already listen on %s", ls->key); + } else { + unlink(ls->key); + } } } free(ls->key);
signature.asc
Description: OpenPGP digital signature