Commit e3a54f06 authored by Jakub Jirutka's avatar Jakub Jirutka

main/php5: rewrite runscript, allow to run multiple masters

parent 96c1ae21
......@@ -4,7 +4,7 @@
# Maintainer: Matt Smith <mcs@darkregion.net>
pkgname=php5
pkgver=5.6.25
pkgrel=0
pkgrel=1
pkgdesc="The PHP language runtime engine"
url="http://www.php.net/"
arch="all"
......@@ -494,17 +494,17 @@ wddx() { _mv_ext wddx; }
opcache() { _mv_ext opcache; }
md5sums="f63b9956c25f1ae0433015a80b44224c php-5.6.25.tar.bz2
11375b4f0aaedc589eba5e31c19e5a7d php-fpm.initd
63b16caff0d7aa881a31a1e02f3080c3 php-fpm.initd
67719f428f44ec004da18705cbabe2ee php5-module.conf
483bc0a85c50a9a9aedbe14a19ed4526 php-install-pear-xml.patch
7200972a23adae799921c4ca20ff0074 gd-iconv.patch"
sha256sums="58ce6032aced7f3e42ced492bd9820e5b3f2a3cd3ef71429aa92fd7b3eb18dde php-5.6.25.tar.bz2
8fc31134677746d5d972d4ed4ab0abe42669e78f46ce45c18bc042b99bc034cd php-fpm.initd
be9bfdab10a994fe553119b181be7015325a7618de454a58bdee06bcfb711454 php-fpm.initd
ceec4d5b2a128c6a97e49830af604f0bb555bca1a86a9cd0366b828ba392257f php5-module.conf
f739ca427a1dd53a388bad0823565299c5d4a5796b1171b892884e4d7d099bab php-install-pear-xml.patch
98de37c650a36870a543225f6a6b81813ccd447a484f0881511be4eb6e901844 gd-iconv.patch"
sha512sums="675a5244822f00abd93ec4ef31c539a4c305cab0aaf4735f6cbe037507853ba3f1691fcbaf1cf54dde106d918c22337bb600ed78c38351d4405da8ffdc5d50e0 php-5.6.25.tar.bz2
ded5cdebc74aeb2d0f0899fe448477ba9eaa01e2e9fbfa6f3425398daccdf26fbe440ab184761cd87b0ea271f97ee237c482a621397d6588c6d353513cdbed1e php-fpm.initd
1f5cb18f85a2e279e24344d993f5c51c7bfbcbecc0e9bfcf075bebd1b0b893e2ffb793d95a632c9333033597d4b4f74840bfd00520a6dc700444d1a054225da1 php-fpm.initd
895e94c791bd82060ad820fef049d366a09c932097faa6b7b9a2c2e9e00a18cb7c0f9b128679c7659b404379266fd0f95dba5c0333f626194cf60f7bf6044102 php5-module.conf
f1177cbf6b1f44402f421c3d317aab1a2a40d0b1209c11519c1158df337c8945f3a313d689c939768584f3e4edbe52e8bd6103fb6777462326a9d94e8ab1f505 php-install-pear-xml.patch
6ecd0be2da1dc5b1d7512e46a2a5cd107a8b2a8c364efc9c624a7d6b2ab081685a329c94c22c970dc14c5c1115f702c512e97ae858da1bc69c6423323dbeeba2 gd-iconv.patch"
#!/sbin/openrc-run
name="PHP FastCGI Process Manager"
cfgfile="/etc/php5/php-fpm.conf"
pidfile="/var/run/php-fpm.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/bin/php-fpm"
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_checkconfig="Run php-fpm config check"
description_reload="Gracefully reload workers and config"
description_reopen="Reopen log files"
extra_started_commands="reload"
required_files="$fpm_config"
depend() {
need net
use apache2 lighttpd nginx
}
init_vars() {
# Defaults for single master process with multiple pools
if [ "$RC_SVCNAME" = "php-fpm" ]; then
: ${fpm_config:="/etc/php5/php-fpm.conf"}
: ${user:="root"}
# Defaults for master process per pool
else
: ${fpm_config="/etc/php5/fpm.d/${RC_SVCNAME#php-fpm.}.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 $name"
start-stop-daemon --signal USR2 --pidfile ${pidfile} --name ${SVCNAME}
start-stop-daemon --signal USR2 --pidfile "$pidfile"
eend $?
}
reopen() {
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
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment