]> git.pld-linux.org Git - packages/php.git/blame - php-fpm.init
cleanups
[packages/php.git] / php-fpm.init
CommitLineData
0fc91222
ER
1#!/bin/sh
2#
9e6915bd 3# @processname@ PHP FastCGI Process Manager
0fc91222
ER
4#
5# chkconfig: 345 80 30
6#
7# description: PHP FastCGI Process Manager
8#
9e6915bd 9# processname: @processname@
1d2cd258 10# config: /etc/php/php-fpm.conf
5151b487 11# pidfile: /var/run/@processname@.pid
0fc91222 12#
0fc91222
ER
13
14# Source function library
15. /etc/rc.d/init.d/functions
16
17# Get network config
18. /etc/sysconfig/network
19
d60d1735
ER
20configfile=/etc/php/php-fpm.conf
21lockfile=/var/lock/subsys/@processname@
22pidfile=$(sed -ne 's,^pid\s*=\s*\(.*\),\1,p' $configfile)
5151b487 23pidfile=${pidfile:-/var/run/@processname@.pid}
0fc91222 24
9e6915bd
ER
25# configtest itself
26# must return non-zero if check failed
27# output is discarded if checkconfig is ran without details
28configtest() {
29 /usr/sbin/@processname@ --fpm-config $configfile -t
30 return $?
31}
32
33# wrapper for configtest
34checkconfig() {
35 local details=${1:-0}
36
37 if [ $details = 1 ]; then
38 # run config test and display report (status action)
39 show "Checking %s configuration" "PHP FastCGI Process Manager"; busy
40 local out
41 out=$(configtest 2>&1)
42 RETVAL=$?
43 if [ $RETVAL = 0 ]; then
44 ok
45 else
46 fail
47 fi
48 [ "$out" ] && echo >&2 "$out"
49 else
50 # run config test and abort with nice message if failed
51 # (for actions checking status before action).
52 configtest >/dev/null 2>&1
53 RETVAL=$?
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
57 exit $RETVAL
58 fi
59 fi
60}
61
0fc91222
ER
62start() {
63 # Check if the service is already running?
4595983b 64 if [ -f $lockfile ]; then
be361f20 65 msg_already_running "PHP FastCGI Process Manager (@processname@)"
4595983b 66 return
0fc91222 67 fi
4595983b 68
9e6915bd 69 checkconfig
d60d1735 70 msg_starting "PHP FastCGI Process Manager (@processname@)"
e8837df1 71 daemon --redirfds --pidfile $pidfile /usr/sbin/@processname@ --fpm-config $configfile
4595983b
ER
72 RETVAL=$?
73 [ $RETVAL -eq 0 ] && touch $lockfile
0fc91222
ER
74}
75
76stop() {
4595983b 77 if [ ! -f $lockfile ]; then
be361f20 78 msg_not_running "PHP FastCGI Process Manager (@processname@)"
4595983b 79 return
0fc91222 80 fi
4595983b
ER
81
82 # Stop daemons.
be361f20 83 msg_stopping "PHP FastCGI Process Manager (@processname@)"
9e6915bd 84 # always gracefully shut down @processname@
4595983b
ER
85 /sbin/start-stop-daemon -q --stop -s QUIT --retry QUIT/600/TERM/10 --pidfile $pidfile
86 [ "$?" -eq 0 ] && ok || fail
87 rm -f $lockfile
0fc91222
ER
88}
89
90reload() {
91 local sig=${1:-HUP}
92 local retnr=${2:-7}
4595983b 93 if [ ! -f $lockfile ]; then
be361f20 94 msg_not_running "PHP FastCGI Process Manager (@processname@)"
0fc91222 95 RETVAL=$retnr
4595983b 96 return
0fc91222 97 fi
4595983b 98
9e6915bd 99 checkconfig
be361f20 100 msg_reloading "PHP FastCGI Process Manager (@processname@)"
9e6915bd 101 killproc --pidfile $pidfile @processname@ -$sig
4595983b 102 RETVAL=$?
0fc91222
ER
103}
104
105condrestart() {
4595983b 106 if [ ! -f $lockfile ]; then
be361f20 107 msg_not_running "PHP FastCGI Process Manager (@processname@)"
0fc91222 108 RETVAL=$1
4595983b 109 return
0fc91222 110 fi
4595983b 111
9e6915bd 112 checkconfig
4595983b
ER
113 stop
114 start
0fc91222
ER
115}
116
117RETVAL=0
118# See how we were called.
119case "$1" in
120 start)
121 start
122 ;;
123 stop|quit)
124 stop
125 ;;
126 restart)
127 stop
128 start
129 ;;
130 try-restart)
131 condrestart 0
132 ;;
133 reload|force-reload)
134 reload USR2 7
135 ;;
9e6915bd
ER
136 checkconfig|configtest)
137 checkconfig 1
138 ;;
0fc91222
ER
139 flush-logs|logrotate)
140 reload USR1 0
141 ;;
142 status)
d60d1735 143 status --pidfile $pidfile @processname@
0fc91222
ER
144 RETVAL=$?
145 ;;
146 *)
9e6915bd 147 msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|flush-logs|checkconfig|status}"
0fc91222
ER
148 exit 3
149 ;;
150esac
151
152exit $RETVAL
This page took 0.051356 seconds and 4 git commands to generate.