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