]> git.pld-linux.org Git - packages/php.git/blob - php-fpm.init
- rel 2; rebuild with apache 2.4
[packages/php.git] / php-fpm.init
1 #!/bin/sh
2 #
3 # php-fpm       PHP FastCGI Process Manager
4 #
5 # chkconfig:    345 80 30
6 #
7 # description:  PHP FastCGI Process Manager
8 #
9 # processname:  php-fpm
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
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}
24
25 start() {
26         # Check if the service is already running?
27         if [ -f $lockfile ]; then
28                 msg_already_running "PHP FastCGI Process Manager"
29                 return
30         fi
31
32         msg_starting "PHP FastCGI Process Manager (@processname@)"
33         daemon --pidfile $pidfile /usr/sbin/@processname@ --fpm-config $configfile
34         RETVAL=$?
35         [ $RETVAL -eq 0 ] && touch $lockfile
36 }
37
38 stop() {
39         if [ ! -f $lockfile ]; then
40                 msg_not_running "PHP FastCGI Process Manager"
41                 return
42         fi
43
44         # Stop daemons.
45         msg_stopping "PHP FastCGI Process Manager"
46         # always gracefully shut down php-fpm
47         /sbin/start-stop-daemon -q --stop -s QUIT --retry QUIT/600/TERM/10 --pidfile $pidfile
48         [ "$?" -eq 0 ] && ok || fail
49         rm -f $lockfile
50 }
51
52 reload() {
53         local sig=${1:-HUP}
54         local retnr=${2:-7}
55         if [ ! -f $lockfile ]; then
56                 msg_not_running "PHP FastCGI Process Manager"
57                 RETVAL=$retnr
58                 return
59         fi
60
61         msg_reloading "PHP FastCGI Process Manager"
62         killproc --pidfile $pidfile php-fpm -$sig
63         RETVAL=$?
64 }
65
66 condrestart() {
67         if [ ! -f $lockfile ]; then
68                 msg_not_running "PHP FastCGI Process Manager"
69                 RETVAL=$1
70                 return
71         fi
72
73         stop
74         start
75 }
76
77 RETVAL=0
78 # See how we were called.
79 case "$1" in
80   start)
81         start
82         ;;
83   stop|quit)
84         stop
85         ;;
86   restart)
87         stop
88         start
89         ;;
90   try-restart)
91         condrestart 0
92         ;;
93   reload|force-reload)
94         reload USR2 7
95         ;;
96   flush-logs|logrotate)
97         reload USR1 0
98         ;;
99   status)
100         status  --pidfile $pidfile @processname@
101         RETVAL=$?
102         ;;
103   *)
104         msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|flush-logs|status}"
105         exit 3
106         ;;
107 esac
108
109 exit $RETVAL
This page took 0.027871 seconds and 3 git commands to generate.