diff options
author | Jakub Jirutka <jakub@jirutka.cz> | 2016-09-22 01:41:24 +0200 |
---|---|---|
committer | Jakub Jirutka <jakub@jirutka.cz> | 2016-09-22 01:52:53 +0200 |
commit | e6fd4a5cf8d0ee7990a3c37d088e9b48f6245b95 (patch) | |
tree | 0388b0f3d2bdfa113c3ca602c6ac4898ea4cad7e | |
parent | e3a54f061a9c88a49044b6e80172ff7760e6c144 (diff) | |
download | aports-e6fd4a5cf8d0ee7990a3c37d088e9b48f6245b95.tar.bz2 aports-e6fd4a5cf8d0ee7990a3c37d088e9b48f6245b95.tar.xz |
community/php7: rewrite runscript, allow to run multiple masters
-rw-r--r-- | community/php7/APKBUILD | 8 | ||||
-rw-r--r-- | community/php7/php7-fpm.initd | 86 |
2 files changed, 76 insertions, 18 deletions
diff --git a/community/php7/APKBUILD b/community/php7/APKBUILD index e2c362f9b8..daaf83f6f7 100644 --- a/community/php7/APKBUILD +++ b/community/php7/APKBUILD @@ -3,7 +3,7 @@ pkgname=php7 _pkgreal=php pkgver=7.0.10 -pkgrel=2 +pkgrel=3 pkgdesc="The PHP language runtime engine - 7th branch" url="http://www.php.net/" arch="all" @@ -342,7 +342,7 @@ _package_ext() { } md5sums="cd1d27be3f522b0543e43c8c2b7116e4 php-7.0.10.tar.bz2 -a340f27e83ed4482d2fbb98658ef71cb php7-fpm.initd +4115cbd0843c72adc3bd42fecd6d4540 php7-fpm.initd 25bde13e7894c2930d97fad68d5dd3b3 php7-fpm.logrotate 47be6cd1ed92f21579e15bf2003a709f php7-module.conf 483bc0a85c50a9a9aedbe14a19ed4526 install-pear.patch @@ -351,7 +351,7 @@ d872e633c9b33c3c9f629dd2edd2e5c5 includedir.patch 6ba762ab7a105163b8e5b3913deae109 pid_log.patch 0c066f4c7f6cbc2e26379ce565197d26 fix-x86-build-bug_571658.patch" sha256sums="8055bbe5a736986931c0c6a08b765d6d778271ec7d2d56c50a1ad259ec09f6de php-7.0.10.tar.bz2 -eca59e8b0498c1c93b35f9a5109ae56d0cda9d94822727d689371ccad31b3615 php7-fpm.initd +a7e4fc0eeba18aec019f62ed966915afd82b6b5fb1e1af93b59f964b5bd66172 php7-fpm.initd 6e4406f21b69085714cdb9d9a67c08e27a1c737ab353f9813cb2fc268352d2c6 php7-fpm.logrotate 276c823ee666ea73b36d4e97174eeea05713125b61f7f8681e350453c4123143 php7-module.conf f739ca427a1dd53a388bad0823565299c5d4a5796b1171b892884e4d7d099bab install-pear.patch @@ -360,7 +360,7 @@ ea74966a23b1b54548ee35e9ccc2fc8d2b7c2285c385c44d6b23d9e2f25ea1a7 includedir.pat 0cca8729c64682387a8c44ed74f0966da697f2817152d8d05bb25bedc7eaafec pid_log.patch 64480b65408caaa98af045270337dc074274a8b98b6a1a853df5d21af426d61e fix-x86-build-bug_571658.patch" sha512sums="521ba5f57c1dbd8c8b7c0c2839e7054cce192f6688fd0f6f98bb30802a3bf2990ea3843fd366a18d20960797bd8ff410819847cae5717ec605674fb8a910e0e9 php-7.0.10.tar.bz2 -89076ab8e170a8f886b88bb30aa3e6a6b4463155a18ea53485cc9e3898c81afa3d01fb8403d28a45dc1680f09c645c2d81d8272bc8b9c7ced41e59b0ba226216 php7-fpm.initd +1c708de82d1086f272f484faf6cf6d087af7c31750cc2550b0b94ed723961b363f28a947b015b2dfc0765caea185a75f5d2c2f2b099c948b65c290924f606e4f php7-fpm.initd cacce7bf789467ff40647b7319e3760c6c587218720538516e8d400baa75651f72165c4e28056cd0c1dc89efecb4d00d0d7823bed80b29136262c825ce816691 php7-fpm.logrotate fbf9a1572d37370ec0d126502e1d066e045a992484d8fc4f1e2ede330134c1a15f4029f29fa4daebd48eed78b045dc051ced69fbf1f11efc7ad81d884a639a99 php7-module.conf f1177cbf6b1f44402f421c3d317aab1a2a40d0b1209c11519c1158df337c8945f3a313d689c939768584f3e4edbe52e8bd6103fb6777462326a9d94e8ab1f505 install-pear.patch diff --git a/community/php7/php7-fpm.initd b/community/php7/php7-fpm.initd index 1016c68f0d..f56fdb5234 100644 --- a/community/php7/php7-fpm.initd +++ b/community/php7/php7-fpm.initd @@ -1,35 +1,93 @@ #!/sbin/openrc-run -name="PHP7 FastCGI Process Manager" -cfgfile="/etc/php7/php-fpm.conf" -pidfile="/var/run/php-fpm7.pid" +# If you want to run separate master process per pool, then create a symlink +# to this runscript for each pool. In that mode, the php-fpm daemon is started +# as nobody by default. You can override the user (and group) by declaring +# variable "user" and optionally "group" in conf.d file, or in the $fpm_config +# file (the former has precedence). + +: ${name:="PHP FastCGI Process Manager"} + command="/usr/sbin/php-fpm7" -command_args="--fpm-config $cfgfile --pid $pidfile" -required_files="$cfgfile" +command_background="yes" +start_stop_daemon_args="--quiet" +pidfile="/run/$RC_SVCNAME/php-fpm.pid" +retry="SIGTERM/20" +# configtest is here only for backward compatibility +extra_commands="checkconfig configtest" extra_started_commands="reload reopen" -description_reload="Reload configuration" +description_checkconfig="Run php-fpm config check" +description_reload="Gracefully reload workers and config" description_reopen="Reopen log files" +required_files="$fpm_config" + depend() { need net - before apache2 lighttpd nginx + use apache2 lighttpd nginx +} + +init_vars() { + # Defaults for single master process with multiple pools + if [ "$RC_SVCNAME" = "php-fpm7" ]; then + : ${fpm_config:="/etc/php7/php-fpm.conf"} + : ${user:="root"} + # Defaults for master process per pool + else + : ${fpm_config="/etc/php7/php-fpm.d/${RC_SVCNAME#php-fpm7.}.conf"} + : ${user:="$(conf_get user)"} + : ${user:="nobody"} + : ${group:="$(conf_get group)"} + fi + command_args="--nodaemonize --fpm-config $fpm_config" + start_stop_daemon_args="$start_stop_daemon_args + --user $user ${group:+"--group $group"}" } start_pre() { - ebegin - $command $command_args -t 2>/dev/null - eend $? + checkconfig || return 1 + + # If unix socket is used (instead of TCP/IP), then ensure that the + # directory exists and has correct privileges. + local listen="$(conf_get listen)" + if [ "${listen:0:1}" = "/" ]; then + checkpath -d -o $user:$group "$(dirname "$listen")" + fi + + checkpath -d "$(dirname "$pidfile")" } reload() { - ebegin "Reloading ${SVCNAME} configuration" - start-stop-daemon --signal USR2 --pidfile $pidfile + ebegin "Reloading $name" + start-stop-daemon --signal USR2 --pidfile "$pidfile" eend $? } reopen() { - ebegin Reopening ${SVCNAME} log files"" - start-stop-daemon --signal USR1 --pidfile $pidfile + ebegin "Reopening $name log files" + start-stop-daemon --signal USR1 --pidfile "$pidfile" eend $? } + +checkconfig() { + init_vars + ebegin "Checking $fpm_config" + + local out + out="$(su -s /bin/sh -c "$command --test --fpm-config $fpm_config" $user 2>&1)" || { + printf "%s\n" "$out" + eend 1 "failed, please correct errors above" + return 1 + } +} + +configtest() { + ewarn "configtest is deprecated, use checkconfig instead" + checkconfig +} + +conf_get() { + local key="$1" + sed -nE "s/^${key}\s*=\s*\"?([^\";]+).*/\1/p" "$fpm_config" | head -n 1 +} |