You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gentoo-overlay/app-eselect/eselect-php/files/php-fpm.init-r2

51 lines
1.2 KiB

#!/sbin/openrc-run
extra_started_commands="reload"
set_phpvars() {
PHPSLOT="${SVCNAME#php-fpm-}"
PHP_FPM_PID="/run/php-fpm-${PHPSLOT}.pid"
if [ ${PHPSLOT} = 'php-fpm' ] ; then
PHPSLOT="$(eselect php show fpm)"
PHP_FPM_PID="/run/php-fpm.pid"
fi
PHP_FPM_CONF="/etc/php/fpm-${PHPSLOT}/php-fpm.conf"
}
start() {
ebegin "Starting PHP FastCGI Process Manager"
set_phpvars
start-stop-daemon --start --pidfile "${PHP_FPM_PID}" \
--exec "/usr/lib/${PHPSLOT}/bin/php-fpm" \
-- \
--fpm-config "${PHP_FPM_CONF}" \
--pid "${PHP_FPM_PID}"
local i=0
local timeout=5
while [ ! -f "${PHP_FPM_PID}" ] && [ $i -le $timeout ]; do
sleep 1
i=$(($i + 1))
done
[ $timeout -gt $i ]
eend $?
}
stop() {
ebegin "Stopping PHP FastCGI Process Manager"
set_phpvars
start-stop-daemon --signal QUIT \
--stop \
--exec "/usr/lib/${PHPSLOT}/bin/php-fpm" \
--pidfile "${PHP_FPM_PID}"
eend $?
}
reload() {
ebegin "Reloading PHP FastCGI Process Manager"
set_phpvars
[ -f "${PHP_FPM_PID}" ] && kill -USR2 $(cat "${PHP_FPM_PID}")
eend $?
}