X-Git-Url: http://git.pld-linux.org/?a=blobdiff_plain;f=php-fpm.init;h=381be8da71f9af4ee66d0e06c224ed09fe4d793e;hb=45629e6e9bbed84edb75f9580aabea932a696556;hp=b44f905e4bcab06df5f81de15962f1aff7fcf997;hpb=d14d7c5f57f37df924af73c7c1f8527271b4bebc;p=packages%2Fphp.git diff --git a/php-fpm.init b/php-fpm.init index b44f905..381be8d 100644 --- a/php-fpm.init +++ b/php-fpm.init @@ -8,7 +8,7 @@ # # processname: @processname@ # config: /etc/php/php-fpm.conf -# pidfile: /var/run/php/@processname@.pid +# pidfile: /var/run/@processname@.pid # # Source function library @@ -20,7 +20,44 @@ 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/php/@processname@.pid} +pidfile=${pidfile:-/var/run/@processname@.pid} + +# configtest itself +# must return non-zero if check failed +# output is discarded if checkconfig is ran without details +configtest() { + /usr/sbin/@processname@ --fpm-config $configfile -t + return $? +} + +# wrapper for configtest +checkconfig() { + local details=${1:-0} + + if [ $details = 1 ]; then + # run config test and display report (status action) + show "Checking %s configuration" "PHP FastCGI Process Manager"; busy + local out + out=$(configtest 2>&1) + RETVAL=$? + if [ $RETVAL = 0 ]; then + ok + else + fail + fi + [ "$out" ] && echo >&2 "$out" + else + # run config test and abort with nice message if failed + # (for actions checking status before action). + configtest >/dev/null 2>&1 + RETVAL=$? + if [ $RETVAL != 0 ]; then + show "Checking %s configuration" "PHP FastCGI Process Manager"; fail + nls 'Configuration test failed. See details with %s "checkconfig"' $0 + exit $RETVAL + fi + fi +} start() { # Check if the service is already running? @@ -29,8 +66,9 @@ start() { return fi + checkconfig msg_starting "PHP FastCGI Process Manager (@processname@)" - daemon --pidfile $pidfile /usr/sbin/@processname@ --fpm-config $configfile + daemon --redirfds --pidfile $pidfile /usr/sbin/@processname@ --fpm-config $configfile RETVAL=$? [ $RETVAL -eq 0 ] && touch $lockfile } @@ -58,6 +96,7 @@ reload() { return fi + checkconfig msg_reloading "PHP FastCGI Process Manager (@processname@)" killproc --pidfile $pidfile @processname@ -$sig RETVAL=$? @@ -70,6 +109,7 @@ condrestart() { return fi + checkconfig stop start } @@ -93,6 +133,9 @@ case "$1" in reload|force-reload) reload USR2 7 ;; + checkconfig|configtest) + checkconfig 1 + ;; flush-logs|logrotate) reload USR1 0 ;; @@ -101,7 +144,7 @@ case "$1" in RETVAL=$? ;; *) - msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|flush-logs|status}" + msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|flush-logs|checkconfig|status}" exit 3 ;; esac