]>
Commit | Line | Data |
---|---|---|
0fc91222 ER |
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 | # | |
1d2cd258 ER |
9 | # processname: php-fpm |
10 | # config: /etc/php/php-fpm.conf | |
0fc91222 ER |
11 | # pidfile: /var/run/php/fpm.pid |
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 | ||
4595983b ER |
20 | pidfile=/var/run/php/php-fpm.pid |
21 | lockfile=/var/lock/subsys/php-fpm | |
0fc91222 ER |
22 | |
23 | start() { | |
24 | # Check if the service is already running? | |
4595983b | 25 | if [ -f $lockfile ]; then |
0fc91222 | 26 | msg_already_running "PHP FastCGI Process Manager" |
4595983b | 27 | return |
0fc91222 | 28 | fi |
4595983b ER |
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 | |
0fc91222 ER |
34 | } |
35 | ||
36 | stop() { | |
4595983b | 37 | if [ ! -f $lockfile ]; then |
0fc91222 | 38 | msg_not_running "PHP FastCGI Process Manager" |
4595983b | 39 | return |
0fc91222 | 40 | fi |
4595983b ER |
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 | |
0fc91222 ER |
48 | } |
49 | ||
50 | reload() { | |
51 | local sig=${1:-HUP} | |
52 | local retnr=${2:-7} | |
4595983b | 53 | if [ ! -f $lockfile ]; then |
0fc91222 ER |
54 | msg_not_running "PHP FastCGI Process Manager" |
55 | RETVAL=$retnr | |
4595983b | 56 | return |
0fc91222 | 57 | fi |
4595983b ER |
58 | |
59 | msg_reloading "PHP FastCGI Process Manager" | |
60 | killproc --pidfile $pidfile php-fpm -$sig | |
61 | RETVAL=$? | |
0fc91222 ER |
62 | } |
63 | ||
64 | condrestart() { | |
4595983b | 65 | if [ ! -f $lockfile ]; then |
0fc91222 ER |
66 | msg_not_running "PHP FastCGI Process Manager" |
67 | RETVAL=$1 | |
4595983b | 68 | return |
0fc91222 | 69 | fi |
4595983b ER |
70 | |
71 | stop | |
72 | start | |
0fc91222 ER |
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) | |
6a65c24a | 98 | status php-fpm |
0fc91222 ER |
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 |