]> git.pld-linux.org Git - packages/php.git/blame_incremental - php-fpm.init
- unified bzip2 bcond name
[packages/php.git] / php-fpm.init
... / ...
CommitLineData
1#!/bin/sh
2#
3# @processname@ PHP FastCGI Process Manager
4#
5# chkconfig: 345 80 30
6#
7# description: PHP FastCGI Process Manager
8#
9# processname: @processname@
10# config: /etc/php/php-fpm.conf
11# pidfile: /var/run/@processname@.pid
12#
13
14# Source function library
15. /etc/rc.d/init.d/functions
16
17# Get network config
18. /etc/sysconfig/network
19
20configfile=/etc/php/php-fpm.conf
21lockfile=/var/lock/subsys/@processname@
22pidfile=$(sed -ne 's,^pid\s*=\s*\(.*\),\1,p' $configfile)
23pidfile=${pidfile:-/var/run/@processname@.pid}
24
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
62start() {
63 # Check if the service is already running?
64 if [ -f $lockfile ]; then
65 msg_already_running "PHP FastCGI Process Manager (@processname@)"
66 return
67 fi
68
69 checkconfig
70 msg_starting "PHP FastCGI Process Manager (@processname@)"
71 daemon --redirfds --pidfile $pidfile /usr/sbin/@processname@ --fpm-config $configfile
72 RETVAL=$?
73 [ $RETVAL -eq 0 ] && touch $lockfile
74}
75
76stop() {
77 if [ ! -f $lockfile ]; then
78 msg_not_running "PHP FastCGI Process Manager (@processname@)"
79 return
80 fi
81
82 # Stop daemons.
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
87 rm -f $lockfile
88}
89
90reload() {
91 local sig=${1:-HUP}
92 local retnr=${2:-7}
93 if [ ! -f $lockfile ]; then
94 msg_not_running "PHP FastCGI Process Manager (@processname@)"
95 RETVAL=$retnr
96 return
97 fi
98
99 checkconfig
100 msg_reloading "PHP FastCGI Process Manager (@processname@)"
101 killproc --pidfile $pidfile @processname@ -$sig
102 RETVAL=$?
103}
104
105condrestart() {
106 if [ ! -f $lockfile ]; then
107 msg_not_running "PHP FastCGI Process Manager (@processname@)"
108 RETVAL=$1
109 return
110 fi
111
112 checkconfig
113 stop
114 start
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 ;;
136 checkconfig|configtest)
137 checkconfig 1
138 ;;
139 flush-logs|logrotate)
140 reload USR1 0
141 ;;
142 status)
143 status --pidfile $pidfile @processname@
144 RETVAL=$?
145 ;;
146 *)
147 msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|flush-logs|checkconfig|status}"
148 exit 3
149 ;;
150esac
151
152exit $RETVAL
This page took 0.204901 seconds and 4 git commands to generate.