X-Git-Url: https://git.pld-linux.org/?a=blobdiff_plain;f=php-fpm.init;h=6cc104acf01af43b71479a04a71aaac67480c2e9;hb=acac87b08ff7d70bf3fda39f672aa1831a61ed67;hp=943d78d423c92ea5cb8aea96dc7a4094ac4e81a4;hpb=04aad4bac62b90707c590fdd130543fe96aa6291;p=packages%2Fphp.git diff --git a/php-fpm.init b/php-fpm.init index 943d78d..6cc104a 100644 --- a/php-fpm.init +++ b/php-fpm.init @@ -1,16 +1,15 @@ #!/bin/sh # -# php-fpm PHP FastCGI Process Manager +# @processname@ PHP FastCGI Process Manager # # chkconfig: 345 80 30 # # description: PHP FastCGI Process Manager # -# processname: php.fpm +# processname: @processname@ # config: /etc/php/fpm.conf -# pidfile: /var/run/php/fpm.pid +# pidfile: /var/run/@processname@.pid # -# $Id$ # Source function library . /etc/rc.d/init.d/functions @@ -18,53 +17,61 @@ # Get network config . /etc/sysconfig/network -pidfile=/var/run/php/fpm.pid +configfile=/etc/php/fpm.conf +lockfile=/var/lock/subsys/@processname@ +pidfile=$(sed -ne 's,.*"\?pid_file"\?>\([^<]\+\)<.*,\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 /usr/bin/php.fpm --fpm --fpm-config /etc/php/fpm.conf - RETVAL=$? - [ $RETVAL -eq 0 ] && touch /var/lock/subsys/php-fpm - else - msg_already_running "PHP FastCGI Process Manager" + if [ -f $lockfile ]; then + msg_already_running "PHP FastCGI Process Manager (@processname@)" + return fi + + msg_starting "PHP FastCGI Process Manager (@processname@)" + daemon --pidfile $pidfile /usr/sbin/@processname@ --fpm --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 - killproc --pidfile $pidfile php-fpm -QUIT - rm -f /var/lock/subsys/php-fpm - else - msg_not_running "PHP FastCGI Process Manager" + if [ ! -f $lockfile ]; then + msg_not_running "PHP FastCGI Process Manager (@processname@)" + return fi + + # Stop daemons. + msg_stopping "PHP FastCGI Process Manager (@processname@)" + # always gracefully shut down @processname@ + /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 - msg_not_running "PHP FastCGI Process Manager" + if [ ! -f $lockfile ]; then + msg_not_running "PHP FastCGI Process Manager (@processname@)" RETVAL=$retnr + return fi + + msg_reloading "PHP FastCGI Process Manager (@processname@)" + killproc --pidfile $pidfile @processname@ -$sig + RETVAL=$? } condrestart() { - if [ -f /var/lock/subsys/php-fpm ]; then - stop - start - else - msg_not_running "PHP FastCGI Process Manager" + if [ ! -f $lockfile ]; then + msg_not_running "PHP FastCGI Process Manager (@processname@)" RETVAL=$1 + return fi + + stop + start } RETVAL=0 @@ -90,7 +97,7 @@ case "$1" in reload USR1 0 ;; status) - status php-fpm php.fpm + status --pidfile $pidfile @processname@ RETVAL=$? ;; *)