diff --git a/sapi/fpm/fpm/fpm.h b/sapi/fpm/fpm/fpm.h index 5ac3ea910669..cf12d42d33ac 100644 --- a/sapi/fpm/fpm/fpm.h +++ b/sapi/fpm/fpm/fpm.h @@ -34,6 +34,7 @@ #define FPM_EXIT_CONFIG 78 #endif +#define FPM_EXIT_MAX_REQUESTS 2 int fpm_run(int *max_requests); int fpm_init(int argc, char **argv, char *config, char *prefix, char *pid, int test_conf, int run_as_root, int force_daemon, int force_stderr); diff --git a/sapi/fpm/fpm/fpm_children.c b/sapi/fpm/fpm/fpm_children.c index bda85ef5a86b..48a5c6ef1634 100644 --- a/sapi/fpm/fpm/fpm_children.c +++ b/sapi/fpm/fpm/fpm_children.c @@ -198,7 +198,10 @@ void fpm_children_bury() /* {{{ */ restart_child = 0; } - if (WEXITSTATUS(status) != FPM_EXIT_OK) { + /* Don't restart processes for pm.ondemand if pm.max_requests has been reached. */ + if (child && child->wp->config->pm == PM_STYLE_ONDEMAND && WEXITSTATUS(status) == FPM_EXIT_MAX_REQUESTS) { + restart_child = 0; + } else if (WEXITSTATUS(status) != FPM_EXIT_OK) { severity = ZLOG_WARNING; } @@ -250,6 +253,8 @@ void fpm_children_bury() /* {{{ */ severity = ZLOG_DEBUG; } zlog(severity, "[pool %s] child %d exited %s after %ld.%06d seconds from start", child->wp->config->name, (int) pid, buf, tv2.tv_sec, (int) tv2.tv_usec); + } else if (WEXITSTATUS(status) == FPM_EXIT_MAX_REQUESTS) { + zlog(ZLOG_DEBUG, "[pool %s] child %d served pm.max_requests after %ld.%06d seconds from start", child->wp->config->name, (int) pid, tv2.tv_sec, (int) tv2.tv_usec); } else { zlog(ZLOG_DEBUG, "[pool %s] child %d has been killed by the process management after %ld.%06d seconds from start", child->wp->config->name, (int) pid, tv2.tv_sec, (int) tv2.tv_usec); } diff --git a/sapi/fpm/fpm/fpm_main.c b/sapi/fpm/fpm/fpm_main.c index f0cc3a07a485..40d12c3fd6cc 100644 --- a/sapi/fpm/fpm/fpm_main.c +++ b/sapi/fpm/fpm/fpm_main.c @@ -1997,6 +1997,7 @@ consult the installation file that came with this distribution, or visit \n\ if (UNEXPECTED(max_requests && (requests == max_requests))) { fcgi_request_set_keep(request, 0); fcgi_finish_request(request, 0); + exit_status = FPM_EXIT_MAX_REQUESTS; break; } /* end of fastcgi loop */