X-Git-Url: http://git.pld-linux.org/?a=blobdiff_plain;f=php-fpm.init;h=125922be2c5d652452f96586ecfdf1c2a0657243;hb=d758c359ead1ebd7c7272f39e7d7cdb3ef0ecae0;hp=e63c2a506b069d067c114a2a228e7c162fab5a20;hpb=0fc912227305ba845c1f8955883086ec4ef72190;p=packages%2Fphp.git diff --git a/php-fpm.init b/php-fpm.init index e63c2a5..125922b 100644 --- a/php-fpm.init +++ b/php-fpm.init @@ -6,11 +6,10 @@ # # description: PHP FastCGI Process Manager # -# processname: php.fpm -# config: /etc/php/fpm.conf -# pidfile: /var/run/php/fpm.pid +# processname: php-fpm +# config: /etc/php/php-fpm.conf +# pidfile: /var/run/@processname@.pid # -# $Id$ # Source function library . /etc/rc.d/init.d/functions @@ -18,54 +17,61 @@ # Get network config . /etc/sysconfig/network -pidfile=/var/run/php/fpm.pid +configfile=/etc/php/php-fpm.conf +lockfile=/var/lock/subsys/@processname@ +pidfile=$(sed -ne 's,^pid\s*=\s*\(.*\),\1,p' $configfile) +pidfile=${pidfile:-/var/run/@processname@.pid} start() { # Check if the service is already running? - if [ ! -f /var/lock/subsys/php-fpm ]; then - msg_starting "PHP FastCGI Process Manager" - daemon --pidfile $pidfile /usr/bin/php.fpm --fpm --fpm-config /etc/php/fpm.conf - RETVAL=$? - [ $RETVAL -eq 0 ] && touch /var/lock/subsys/php-fpm - else + if [ -f $lockfile ]; then msg_already_running "PHP FastCGI Process Manager" + return fi + + msg_starting "PHP FastCGI Process Manager (@processname@)" + daemon --pidfile $pidfile /usr/sbin/@processname@ --fpm-config $configfile + RETVAL=$? + [ $RETVAL -eq 0 ] && touch $lockfile } stop() { - if [ -f /var/lock/subsys/php-fpm ]; then - # Stop daemons. - msg_stopping "PHP FastCGI Process Manager" - # always gracefully shut down php-fpm - /sbin/start-stop-daemon -q --stop -s QUIT --retry QUIT/600/TERM/10 --pidfile $pidfile - [ "$?" -eq 0 ] && ok || fail - rm -f /var/lock/subsys/php-fpm - else + if [ ! -f $lockfile ]; then msg_not_running "PHP FastCGI Process Manager" + return fi + + # Stop daemons. + msg_stopping "PHP FastCGI Process Manager" + # always gracefully shut down php-fpm + /sbin/start-stop-daemon -q --stop -s QUIT --retry QUIT/600/TERM/10 --pidfile $pidfile + [ "$?" -eq 0 ] && ok || fail + rm -f $lockfile } reload() { local sig=${1:-HUP} local retnr=${2:-7} - if [ -f /var/lock/subsys/php-fpm ]; then - msg_reloading "PHP FastCGI Process Manager" - killproc --pidfile $pidfile php-fpm -$sig - RETVAL=$? - else + if [ ! -f $lockfile ]; then msg_not_running "PHP FastCGI Process Manager" RETVAL=$retnr + return fi + + msg_reloading "PHP FastCGI Process Manager" + killproc --pidfile $pidfile php-fpm -$sig + RETVAL=$? } condrestart() { - if [ -f /var/lock/subsys/php-fpm ]; then - stop - start - else + if [ ! -f $lockfile ]; then msg_not_running "PHP FastCGI Process Manager" RETVAL=$1 + return fi + + stop + start } RETVAL=0 @@ -91,7 +97,7 @@ case "$1" in reload USR1 0 ;; status) - status php-fpm php.fpm + status --pidfile $pidfile @processname@ RETVAL=$? ;; *)