diff options
author | Suren A. Chilingaryan <csa@suren.me> | 2019-09-01 00:00:32 +0200 |
---|---|---|
committer | Suren A. Chilingaryan <csa@suren.me> | 2019-09-01 00:00:32 +0200 |
commit | ca9627e70852f6b2e835660df870fe3ab405882d (patch) | |
tree | 0a008b1d5b16fa0679a195ed7b5662c7891f591c /dev-lang/php/files/php-fpm-r4.init | |
download | darklin4-ca9627e70852f6b2e835660df870fe3ab405882d.tar.gz darklin4-ca9627e70852f6b2e835660df870fe3ab405882d.tar.bz2 darklin4-ca9627e70852f6b2e835660df870fe3ab405882d.tar.xz darklin4-ca9627e70852f6b2e835660df870fe3ab405882d.zip |
Initial import
Diffstat (limited to 'dev-lang/php/files/php-fpm-r4.init')
-rwxr-xr-x | dev-lang/php/files/php-fpm-r4.init | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/dev-lang/php/files/php-fpm-r4.init b/dev-lang/php/files/php-fpm-r4.init new file mode 100755 index 0000000..a186d83 --- /dev/null +++ b/dev-lang/php/files/php-fpm-r4.init @@ -0,0 +1,47 @@ +#!/sbin/runscript + +set_phpvars() { + PHPSLOT=${SVCNAME#php-fpm-} + [ ${PHPSLOT} = 'php-fpm' ] && PHPSLOT="$(eselect php show fpm)" + + PHP_FPM_CONF="/etc/php/fpm-${PHPSLOT}/php-fpm.conf" + PHP_FPM_PID="/var/run/php-fpm-${PHPSLOT}.pid" +} + +extra_commands="depend" +extra_started_commands="reload" + +depend() { + need net + use apache2 lighttpd nginx +} + +start() { + ebegin "Starting PHP FastCGI Process Manager" + set_phpvars + start-stop-daemon --start --pidfile ${PHP_FPM_PID} --exec \ + /usr/lib/${PHPSLOT}/bin/php-fpm -- -y "${PHP_FPM_CONF}" -g "${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 $? +} |