summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemi Collet <fedora@famillecollet.com>2012-09-19 17:28:44 +0200
committerRemi Collet <fedora@famillecollet.com>2012-09-19 17:28:44 +0200
commit7f2986bfba8e2e4cd5c1f5b17d558e048b7bf023 (patch)
tree195a4991ad04efb9cced1ad0295d95e6d81639d5
parent6e0dd3dee5a7173aef26d9b3ba65931e561483a0 (diff)
add --daemonize / --nodaemonize options to php-fpm, upstream RFE: https://bugs.php.net/63085
-rw-r--r--php-5.4.7-63085.patch236
-rwxr-xr-xphp-fpm.init2
-rw-r--r--php-fpm.service3
-rw-r--r--php54.spec14
4 files changed, 247 insertions, 8 deletions
diff --git a/php-5.4.7-63085.patch b/php-5.4.7-63085.patch
new file mode 100644
index 0000000..b5d2ff6
--- /dev/null
+++ b/php-5.4.7-63085.patch
@@ -0,0 +1,236 @@
+diff -Nru sapi/fpm.old/config.m4 sapi/fpm/config.m4
+--- sapi/fpm.old/config.m4 2012-09-19 15:53:48.001758347 +0200
++++ sapi/fpm/config.m4 2012-09-19 16:18:57.661936394 +0200
+@@ -589,7 +589,7 @@
+
+ PHP_ADD_BUILD_DIR(sapi/fpm/fpm)
+ PHP_ADD_BUILD_DIR(sapi/fpm/fpm/events)
+- PHP_OUTPUT(sapi/fpm/php-fpm.conf sapi/fpm/init.d.php-fpm sapi/fpm/php-fpm.8 sapi/fpm/status.html)
++ PHP_OUTPUT(sapi/fpm/php-fpm.conf sapi/fpm/init.d.php-fpm sapi/fpm/php-fpm.service sapi/fpm/php-fpm.8 sapi/fpm/status.html)
+ PHP_ADD_MAKEFILE_FRAGMENT([$abs_srcdir/sapi/fpm/Makefile.frag])
+
+ SAPI_FPM_PATH=sapi/fpm/php-fpm
+diff -Nru sapi/fpm.old/fpm/fpm.c sapi/fpm/fpm/fpm.c
+--- sapi/fpm.old/fpm/fpm.c 2012-09-19 15:53:48.000758297 +0200
++++ sapi/fpm/fpm/fpm.c 2012-09-19 16:09:57.462102346 +0200
+@@ -42,7 +42,7 @@
+ .send_config_signal = 0,
+ };
+
+-int fpm_init(int argc, char **argv, char *config, char *prefix, char *pid, int test_conf, int run_as_root) /* {{{ */
++int fpm_init(int argc, char **argv, char *config, char *prefix, char *pid, int test_conf, int run_as_root, int force_daemon) /* {{{ */
+ {
+ fpm_globals.argc = argc;
+ fpm_globals.argv = argv;
+@@ -55,7 +55,7 @@
+
+ if (0 > fpm_php_init_main() ||
+ 0 > fpm_stdio_init_main() ||
+- 0 > fpm_conf_init_main(test_conf) ||
++ 0 > fpm_conf_init_main(test_conf, force_daemon) ||
+ 0 > fpm_unix_init_main() ||
+ 0 > fpm_scoreboard_init_main() ||
+ 0 > fpm_pctl_init_main() ||
+diff -Nru sapi/fpm.old/fpm/fpm_conf.c sapi/fpm/fpm/fpm_conf.c
+--- sapi/fpm.old/fpm/fpm_conf.c 2012-09-19 15:53:48.000758297 +0200
++++ sapi/fpm/fpm/fpm_conf.c 2012-09-19 16:08:46.034854345 +0200
+@@ -1115,7 +1115,7 @@
+ }
+ /* }}} */
+
+-static int fpm_conf_post_process(TSRMLS_D) /* {{{ */
++static int fpm_conf_post_process(int force_daemon TSRMLS_DC) /* {{{ */
+ {
+ struct fpm_worker_pool_s *wp;
+
+@@ -1123,6 +1123,11 @@
+ fpm_evaluate_full_path(&fpm_global_config.pid_file, NULL, PHP_LOCALSTATEDIR, 0);
+ }
+
++ if (force_daemon >= 0) {
++ /* forced from command line options */
++ fpm_global_config.daemonize = force_daemon;
++ }
++
+ fpm_globals.log_level = fpm_global_config.log_level;
+
+ if (fpm_global_config.process_max < 0) {
+@@ -1584,7 +1589,7 @@
+ }
+ /* }}} */
+
+-int fpm_conf_init_main(int test_conf) /* {{{ */
++int fpm_conf_init_main(int test_conf, int force_daemon) /* {{{ */
+ {
+ int ret;
+ TSRMLS_FETCH();
+@@ -1630,7 +1635,7 @@
+ return -1;
+ }
+
+- if (0 > fpm_conf_post_process(TSRMLS_C)) {
++ if (0 > fpm_conf_post_process(force_daemon TSRMLS_CC)) {
+ zlog(ZLOG_ERROR, "failed to post process the configuration");
+ return -1;
+ }
+diff -Nru sapi/fpm.old/fpm/fpm_conf.h sapi/fpm/fpm/fpm_conf.h
+--- sapi/fpm.old/fpm/fpm_conf.h 2012-09-19 15:53:48.000758297 +0200
++++ sapi/fpm/fpm/fpm_conf.h 2012-09-19 16:05:29.874174589 +0200
+@@ -97,7 +97,7 @@
+ PM_STYLE_ONDEMAND = 3
+ };
+
+-int fpm_conf_init_main(int test_conf);
++int fpm_conf_init_main(int test_conf, int force_daemon);
+ int fpm_worker_pool_config_free(struct fpm_worker_pool_config_s *wpc);
+ int fpm_conf_write_pid();
+ int fpm_conf_unlink_pid();
+diff -Nru sapi/fpm.old/fpm/fpm.h sapi/fpm/fpm/fpm.h
+--- sapi/fpm.old/fpm/fpm.h 2012-09-19 15:53:48.000758297 +0200
++++ sapi/fpm/fpm/fpm.h 2012-09-19 16:02:06.113470905 +0200
+@@ -37,7 +37,7 @@
+
+
+ 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 fpm_init(int argc, char **argv, char *config, char *prefix, char *pid, int test_conf, int run_as_root, int force_daemon);
+
+ struct fpm_globals_s {
+ pid_t parent_pid;
+diff -Nru sapi/fpm.old/fpm/fpm_main.c sapi/fpm/fpm/fpm_main.c
+--- sapi/fpm.old/fpm/fpm_main.c 2012-09-19 15:53:47.999758244 +0200
++++ sapi/fpm/fpm/fpm_main.c 2012-09-19 16:29:52.595853439 +0200
+@@ -155,6 +155,8 @@
+ {'p', 1, "prefix"},
+ {'g', 1, "pid"},
+ {'R', 0, "allow-to-run-as-root"},
++ {'D', 0, "daemonize"},
++ {'F', 0, "nodaemonize"},
+ {'-', 0, NULL} /* end of args */
+ };
+
+@@ -912,7 +914,7 @@
+ prog = "php";
+ }
+
+- php_printf( "Usage: %s [-n] [-e] [-h] [-i] [-m] [-v] [-t] [-p <prefix>] [-g <pid>] [-c <file>] [-d foo[=bar]] [-y <file>]\n"
++ php_printf( "Usage: %s [-n] [-e] [-h] [-i] [-m] [-v] [-t] [-p <prefix>] [-g <pid>] [-c <file>] [-d foo[=bar]] [-y <file>] [-D] [-F]\n"
+ " -c <path>|<file> 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"
+@@ -928,6 +930,9 @@
+ " -y, --fpm-config <file>\n"
+ " Specify alternative path to FastCGI process manager config file.\n"
+ " -t, --test Test FPM configuration and exit\n"
++ " -D, --daemonize force to run in background, and ignore daemonize option from config file\n"
++ " F, --nodaemonize\n"
++ " force to stay in foreground, and ignore daemonize option from config file\n"
+ " -R, --allow-to-run-as-root\n"
+ " Allow pool to run as root (disabled by default)\n",
+ prog, PHP_PREFIX);
+@@ -1550,6 +1555,7 @@
+ char *fpm_prefix = NULL;
+ char *fpm_pid = NULL;
+ int test_conf = 0;
++ int force_daemon = -1;
+ int php_information = 0;
+ int php_allow_to_run_as_root = 0;
+
+@@ -1670,6 +1676,14 @@
+ php_allow_to_run_as_root = 1;
+ break;
+
++ case 'D': /* daemonize */
++ force_daemon = 1;
++ break;
++
++ case 'F': /* nodaemonize */
++ force_daemon = 0;
++ break;
++
+ default:
+ case 'h':
+ case '?':
+@@ -1797,7 +1811,7 @@
+ }
+ }
+
+- if (0 > fpm_init(argc, argv, fpm_config ? fpm_config : CGIG(fpm_config), fpm_prefix, fpm_pid, test_conf, php_allow_to_run_as_root)) {
++ if (0 > fpm_init(argc, argv, fpm_config ? fpm_config : CGIG(fpm_config), fpm_prefix, fpm_pid, test_conf, php_allow_to_run_as_root, force_daemon)) {
+
+ if (fpm_globals.send_config_signal) {
+ zlog(ZLOG_DEBUG, "Sending SIGUSR2 (error) to parent %d", getppid());
+diff -Nru sapi/fpm.old/init.d.php-fpm.in sapi/fpm/init.d.php-fpm.in
+--- sapi/fpm.old/init.d.php-fpm.in 2012-09-19 15:53:47.998758183 +0200
++++ sapi/fpm/init.d.php-fpm.in 2012-09-19 16:12:13.356570094 +0200
+@@ -54,7 +54,7 @@
+ start)
+ echo -n "Starting php-fpm "
+
+- $php_fpm_BIN $php_opts
++ $php_fpm_BIN --daemonize $php_opts
+
+ if [ "$?" != 0 ] ; then
+ echo " failed"
+diff -Nru sapi/fpm.old/php-fpm.8.in sapi/fpm/php-fpm.8.in
+--- sapi/fpm.old/php-fpm.8.in 2012-09-19 15:53:47.998758183 +0200
++++ sapi/fpm/php-fpm.8.in 2012-09-19 16:40:57.865863325 +0200
+@@ -99,6 +99,20 @@
+ If called twice (-tt), the configuration is dumped before exiting.
+ .TP
+ .PD 0
++.B \-\-daemonize
++.TP
++.PD 1
++.B \-D
++Force to run in background and ignore daemonize option from configuration file.
++.TP
++.PD 0
++.B \-\-nodaemonize
++.TP
++.PD 1
++.B \-F
++Force to stay in foreground and ignore daemonize option from configuration file.
++.TP
++.PD 0
+ .B \-\-zend\-extension \fIfile\fP
+ .TP
+ .PD 1
+@@ -113,13 +127,20 @@
+ .B php.ini
+ The standard php configuration file.
+ .SH EXAMPLES
+-You should use the init script provided to start and stop the php-fpm daemon. This situation applies for any unix systems which use init.d for their main process manager.
++For any unix systems which use init.d for their main process manager, you should use the init script provided to start and stop the php-fpm daemon.
+ .P
+ .PD 1
+ .RS
+ sudo /etc/init.d/php-fpm start
+ .RE
+ .TP
++For any unix systems which use systemd for their main process manager, you should use the unit file provided to start and stop the php-fpm daemon.
++.P
++.PD 1
++.RS
++sudo systemctl start php-fpm.service
++.RE
++.TP
+ If your installation has no appropriate init script, launch php-fpm with no arguments. It will launch as a daemon (background process) by default. The file @php_fpm_localstatedir@/run/php-fpm.pid determines whether php-fpm is already up and running. Once started, php-fpm then responds to several POSIX signals:
+ .P
+ .PD 0
+diff -Nru sapi/fpm.old/php-fpm.service.in sapi/fpm/php-fpm.service.in
+--- sapi/fpm.old/php-fpm.service.in 1970-01-01 01:00:00.000000000 +0100
++++ sapi/fpm/php-fpm.service.in 2012-09-19 16:21:32.140467558 +0200
+@@ -0,0 +1,12 @@
++[Unit]
++Description=The PHP FastCGI Process Manager
++After=syslog.target network.target
++
++[Service]
++PIDFile=@localstatedir@/run/php-fpm.pid
++ExecStart=@sbindir@/php-fpm --nodaemonize --fpm-config @sysconfdir@/php-fpm.conf
++ExecReload=/bin/kill -USR2 $MAINPID
++
++[Install]
++WantedBy=multi-user.target
++
diff --git a/php-fpm.init b/php-fpm.init
index e521257..96826a3 100755
--- a/php-fpm.init
+++ b/php-fpm.init
@@ -34,7 +34,7 @@ start () {
echo -n $"Starting $prog: "
dir=$(dirname ${pidfile})
[ -d $dir ] || mkdir $dir
- daemon --pidfile ${pidfile} php-fpm
+ daemon --pidfile ${pidfile} php-fpm --daemonize
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch ${lockfile}
diff --git a/php-fpm.service b/php-fpm.service
index 5aaaf3f..194e330 100644
--- a/php-fpm.service
+++ b/php-fpm.service
@@ -3,10 +3,9 @@ Description=The PHP FastCGI Process Manager
After=syslog.target network.target
[Service]
-Type=forking
PIDFile=/run/php-fpm/php-fpm.pid
EnvironmentFile=/etc/sysconfig/php-fpm
-ExecStart=/usr/sbin/php-fpm
+ExecStart=/usr/sbin/php-fpm --nodaemonize
ExecReload=/bin/kill -USR2 $MAINPID
[Install]
diff --git a/php54.spec b/php54.spec
index bf66181..82e8d83 100644
--- a/php54.spec
+++ b/php54.spec
@@ -65,7 +65,7 @@ Version: 5.4.7
%if 0%{?snapdate:1}%{?rcver:1}
Release: 0.2.%{?snapdate}%{?rcver}%{?dist}
%else
-Release: 5%{?dist}
+Release: 6%{?dist}
%endif
License: PHP
Group: Development/Languages
@@ -103,6 +103,9 @@ Patch42: php-5.3.1-systzdata-v9.patch
Patch43: php-5.4.0-phpize.patch
# Use system libzip instead of bundled one
Patch44: php-5.4.5-system-libzip.patch
+# improves php-fpm daemonize mode
+# see https://bugs.php.net/63085
+Patch45: php-5.4.7-63085.patch
# Fixes for tests
@@ -684,6 +687,7 @@ httpd -V | grep -q 'threaded:.*yes' && exit 1
%if %{with_libzip}
%patch44 -p1 -b .systzip
%endif
+%patch45 -p0 -b .63085
%patch91 -p1 -b .remi-oci8
@@ -1196,10 +1200,6 @@ install -m 755 %{SOURCE99} $RPM_BUILD_ROOT%{_initrddir}/php-fpm
install -m 755 -d $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig
install -m 644 %{SOURCE8} $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/php-fpm
# php-fpm should not fork on recent version
-%if 0%{?fedora} >= 18 || 0%{?rhel} >= 7
-sed -e '/daemonize/s/yes/no/' -e $RPM_BUILD_ROOT%{_sysconfdir}/php-fpm.conf
-sed -e '/forking/d' -e $RPM_BUILD_ROOT%{_unitdir}/php-fpm.service
-%endif
%endif
# Fix the link
@@ -1477,6 +1477,10 @@ fi
%changelog
+* Wed Sep 19 2012 Remi Collet <RPMS@famillecollet.com> 5.4.7-6
+- add --daemonize / --nodaemonize options to php-fpm
+ upstream RFE: https://bugs.php.net/63085
+
* Wed Sep 19 2012 Remi Collet <RPMS@famillecollet.com> 5.4.7-5
- sync with rawhide
- patch to report libdb version https://bugs.php.net/63117