]> gitweb.michael.orlitzky.com - mjo-overlay.git/blob - dev-lang/php/files/php-fpm-r4.init
Add an "any slot" dependency operator for dev-db/postgresql.
[mjo-overlay.git] / dev-lang / php / files / php-fpm-r4.init
1 #!/sbin/runscript
2
3 set_phpvars() {
4 PHPSLOT=${SVCNAME#php-fpm-}
5 [ ${PHPSLOT} = 'php-fpm' ] && PHPSLOT="$(eselect php show fpm)"
6
7 PHP_FPM_CONF="/etc/php/fpm-${PHPSLOT}/php-fpm.conf"
8 PHP_FPM_PID="/var/run/php-fpm-${PHPSLOT}.pid"
9 }
10
11 extra_commands="depend"
12 extra_started_commands="reload"
13
14 depend() {
15 need net
16 use apache2 lighttpd nginx
17 }
18
19 start() {
20 ebegin "Starting PHP FastCGI Process Manager"
21 set_phpvars
22 start-stop-daemon --start --pidfile ${PHP_FPM_PID} --exec \
23 /usr/lib/${PHPSLOT}/bin/php-fpm -- -y "${PHP_FPM_CONF}" -g "${PHP_FPM_PID}"
24 local i=0
25 local timeout=5
26 while [ ! -f ${PHP_FPM_PID} ] && [ $i -le $timeout ]; do
27 sleep 1
28 i=$(($i + 1))
29 done
30
31 [ $timeout -gt $i ]
32 eend $?
33 }
34
35 stop() {
36 ebegin "Stopping PHP FastCGI Process Manager"
37 set_phpvars
38 start-stop-daemon --signal QUIT --stop --exec /usr/lib/${PHPSLOT}/bin/php-fpm --pidfile ${PHP_FPM_PID}
39 eend $?
40 }
41
42 reload() {
43 ebegin "Reloading PHP FastCGI Process Manager"
44 set_phpvars
45 [ -f ${PHP_FPM_PID} ] && kill -USR2 $(cat ${PHP_FPM_PID})
46 eend $?
47 }