Skip to content

Instantly share code, notes, and snippets.

@artixnous
Created March 18, 2017 23:30
Show Gist options
  • Save artixnous/dcadc49049265e49dce6ccf370dbf0cc to your computer and use it in GitHub Desktop.
Save artixnous/dcadc49049265e49dce6ccf370dbf0cc to your computer and use it in GitHub Desktop.
php-fpm-openrc
#!/usr/bin/openrc-run
set_phpvars() {
PHP_FPM_CONF="/etc/php/php-fpm.conf"
PHP_FPM_PID="/run/php-fpm.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/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/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 $?
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment