[packages/php] fpm: add configtest support
glen
glen at pld-linux.org
Thu Dec 12 14:06:56 CET 2013
commit 9e6915bd7fd17ca29748d16e5ef549898984df9a
Author: Elan Ruusamäe <glen at delfi.ee>
Date: Thu Dec 12 15:04:15 2013 +0200
fpm: add configtest support
php-fpm.init | 53 ++++++++++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 48 insertions(+), 5 deletions(-)
---
diff --git a/php-fpm.init b/php-fpm.init
index f58fe0e..2624bca 100755
--- a/php-fpm.init
+++ b/php-fpm.init
@@ -1,12 +1,12 @@
#!/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/php-fpm.conf
# pidfile: /var/run/@processname at .pid
#
@@ -22,6 +22,43 @@ lockfile=/var/lock/subsys/@processname@
pidfile=$(sed -ne 's,^pid\s*=\s*\(.*\),\1,p' $configfile)
pidfile=${pidfile:-/var/run/@processname at .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?
if [ -f $lockfile ]; then
@@ -29,6 +66,7 @@ start() {
return
fi
+ checkconfig
msg_starting "PHP FastCGI Process Manager (@processname@)"
daemon --redirfds --pidfile $pidfile /usr/sbin/@processname@ --fpm-config $configfile
RETVAL=$?
@@ -43,7 +81,7 @@ stop() {
# Stop daemons.
msg_stopping "PHP FastCGI Process Manager"
- # always gracefully shut down php-fpm
+ # 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
@@ -58,8 +96,9 @@ reload() {
return
fi
+ checkconfig
msg_reloading "PHP FastCGI Process Manager"
- killproc --pidfile $pidfile php-fpm -$sig
+ 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
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/php.git/commitdiff/9e6915bd7fd17ca29748d16e5ef549898984df9a
More information about the pld-cvs-commit
mailing list