From 74b693f16b43c3263c07026abd9a0728e26d4fd9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Loyet?= Date: Sat, 2 Jul 2011 23:41:01 +0000 Subject: [PATCH] - Implemented FR #54172 (Overriding the pid file location of php-fpm) --- NEWS | 1 + sapi/fpm/fpm/fpm.c | 4 +++- sapi/fpm/fpm/fpm.h | 3 ++- sapi/fpm/fpm/fpm_conf.c | 4 ++++ sapi/fpm/fpm/fpm_main.c | 12 ++++++++++-- 5 files changed, 20 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 5fb0742d3a..1d5f4e410c 100644 --- a/NEWS +++ b/NEWS @@ -25,6 +25,7 @@ PHP NEWS . Fixed missing Expires and Cache-Control headers for ping and status pages. (fat) . Implemented FR #54499 (FPM ping and status_path should handle HEAD request). (fat) + . Implemented FR #54172 (Overriding the pid file location of php-fpm). (fat) - SPL extension: . Fixed bug #54971 (Wrong result when using iterator_to_array with use_keys diff --git a/sapi/fpm/fpm/fpm.c b/sapi/fpm/fpm/fpm.c index 13106dfe4d..ca0be3d19e 100644 --- a/sapi/fpm/fpm/fpm.c +++ b/sapi/fpm/fpm/fpm.c @@ -29,6 +29,7 @@ struct fpm_globals_s fpm_globals = { .argv = NULL, .config = NULL, .prefix = NULL, + .pid = NULL, .running_children = 0, .error_log_fd = 0, .log_level = 0, @@ -38,7 +39,7 @@ struct fpm_globals_s fpm_globals = { .test_successful = 0 }; -int fpm_init(int argc, char **argv, char *config, char *prefix, int test_conf) /* {{{ */ +int fpm_init(int argc, char **argv, char *config, char *prefix, char *pid, int test_conf) /* {{{ */ { fpm_globals.argc = argc; fpm_globals.argv = argv; @@ -46,6 +47,7 @@ int fpm_init(int argc, char **argv, char *config, char *prefix, int test_conf) / fpm_globals.config = strdup(config); } fpm_globals.prefix = prefix; + fpm_globals.pid = pid; if (0 > fpm_php_init_main() || 0 > fpm_stdio_init_main() || diff --git a/sapi/fpm/fpm/fpm.h b/sapi/fpm/fpm/fpm.h index f06d9ed6a9..3c6f798fba 100644 --- a/sapi/fpm/fpm/fpm.h +++ b/sapi/fpm/fpm/fpm.h @@ -8,7 +8,7 @@ #include int fpm_run(int *max_requests); -int fpm_init(int argc, char **argv, char *config, char *prefix, int test_conf); +int fpm_init(int argc, char **argv, char *config, char *prefix, char *pid, int test_conf); struct fpm_globals_s { pid_t parent_pid; @@ -16,6 +16,7 @@ struct fpm_globals_s { char **argv; char *config; char *prefix; + char *pid; int running_children; int error_log_fd; int log_level; diff --git a/sapi/fpm/fpm/fpm_conf.c b/sapi/fpm/fpm/fpm_conf.c index 07d982393f..0a1494d404 100644 --- a/sapi/fpm/fpm/fpm_conf.c +++ b/sapi/fpm/fpm/fpm_conf.c @@ -1206,6 +1206,10 @@ int fpm_conf_init_main(int test_conf) /* {{{ */ } } + if (fpm_globals.pid && *fpm_globals.pid) { + fpm_global_config.pid_file = strdup(fpm_globals.pid); + } + if (fpm_globals.config == NULL) { char *tmp; diff --git a/sapi/fpm/fpm/fpm_main.c b/sapi/fpm/fpm/fpm_main.c index 414af7e444..09429a9328 100644 --- a/sapi/fpm/fpm/fpm_main.c +++ b/sapi/fpm/fpm/fpm_main.c @@ -155,6 +155,7 @@ static const opt_struct OPTIONS[] = { {'y', 1, "fpm-config"}, {'t', 0, "test"}, {'p', 1, "prefix"}, + {'g', 1, "pid"}, {'-', 0, NULL} /* end of args */ }; @@ -961,7 +962,7 @@ static void php_cgi_usage(char *argv0) prog = "php"; } - php_printf( "Usage: %s [-n] [-e] [-h] [-i] [-m] [-v] [-t] [-p ] [-c ] [-d foo[=bar]] [-y ]\n" + php_printf( "Usage: %s [-n] [-e] [-h] [-i] [-m] [-v] [-t] [-p ] [-g ] [-c ] [-d foo[=bar]] [-y ]\n" " -c | Look for php.ini file in this directory\n" " -n No php.ini file will be used\n" " -d foo[=bar] Define INI entry foo with value 'bar'\n" @@ -972,6 +973,8 @@ static void php_cgi_usage(char *argv0) " -v Version number\n" " -p, --prefix \n" " Specify alternative prefix path to FastCGI process manager (default: %s).\n" + " -g, --pid \n" + " Specify the PID file location.\n" " -y, --fpm-config \n" " Specify alternative path to FastCGI process manager config file.\n" " -t, --test Test FPM configuration and exit\n", @@ -1587,6 +1590,7 @@ int main(int argc, char *argv[]) fcgi_request request; char *fpm_config = NULL; char *fpm_prefix = NULL; + char *fpm_pid = NULL; int test_conf = 0; fcgi_init(); @@ -1670,6 +1674,10 @@ int main(int argc, char *argv[]) fpm_prefix = php_optarg; break; + case 'g': + fpm_pid = php_optarg; + break; + case 'e': /* enable extended info output */ CG(compiler_options) |= ZEND_COMPILE_EXTENDED_INFO; break; @@ -1815,7 +1823,7 @@ consult the installation file that came with this distribution, or visit \n\ } } - if (0 > fpm_init(argc, argv, fpm_config ? fpm_config : CGIG(fpm_config), fpm_prefix, test_conf)) { + if (0 > fpm_init(argc, argv, fpm_config ? fpm_config : CGIG(fpm_config), fpm_prefix, fpm_pid, test_conf)) { return FAILURE; } -- 2.40.0