3 # @processname@ PHP FastCGI Process Manager
7 # description: PHP FastCGI Process Manager
9 # processname: @processname@
10 # config: /etc/php/php-fpm.conf
11 # pidfile: /var/run/@processname@.pid
14 # Source function library
15 . /etc/rc.d/init.d/functions
18 . /etc/sysconfig/network
20 configfile=/etc/php/php-fpm.conf
21 lockfile=/var/lock/subsys/@processname@
22 pidfile=$(sed -ne 's,^pid\s*=\s*\(.*\),\1,p' $configfile)
23 pidfile=${pidfile:-/var/run/@processname@.pid}
26 # must return non-zero if check failed
27 # output is discarded if checkconfig is ran without details
29 /usr/sbin/@processname@ --fpm-config $configfile -t
33 # wrapper for configtest
37 if [ $details = 1 ]; then
38 # run config test and display report (status action)
39 show "Checking %s configuration" "PHP FastCGI Process Manager"; busy
41 out=$(configtest 2>&1)
43 if [ $RETVAL = 0 ]; then
48 [ "$out" ] && echo >&2 "$out"
50 # run config test and abort with nice message if failed
51 # (for actions checking status before action).
52 configtest >/dev/null 2>&1
54 if [ $RETVAL != 0 ]; then
55 show "Checking %s configuration" "PHP FastCGI Process Manager"; fail
56 nls 'Configuration test failed. See details with %s "checkconfig"' $0
63 # Check if the service is already running?
64 if [ -f $lockfile ]; then
65 msg_already_running "PHP FastCGI Process Manager (@processname@)"
70 msg_starting "PHP FastCGI Process Manager (@processname@)"
71 daemon --redirfds --pidfile $pidfile /usr/sbin/@processname@ --fpm-config $configfile
73 [ $RETVAL -eq 0 ] && touch $lockfile
77 if [ ! -f $lockfile ]; then
78 msg_not_running "PHP FastCGI Process Manager (@processname@)"
83 msg_stopping "PHP FastCGI Process Manager (@processname@)"
84 # always gracefully shut down @processname@
85 /sbin/start-stop-daemon -q --stop -s QUIT --retry QUIT/600/TERM/10 --pidfile $pidfile
86 [ "$?" -eq 0 ] && ok || fail
93 if [ ! -f $lockfile ]; then
94 msg_not_running "PHP FastCGI Process Manager (@processname@)"
100 msg_reloading "PHP FastCGI Process Manager (@processname@)"
101 killproc --pidfile $pidfile @processname@ -$sig
106 if [ ! -f $lockfile ]; then
107 msg_not_running "PHP FastCGI Process Manager (@processname@)"
118 # See how we were called.
136 checkconfig|configtest)
139 flush-logs|logrotate)
143 status --pidfile $pidfile @processname@
147 msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|flush-logs|checkconfig|status}"