]>
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 | # | |
13 | # $Id$ | |
14 | ||
15 | # Source function library | |
16 | . /etc/rc.d/init.d/functions | |
17 | ||
18 | # Get network config | |
19 | . /etc/sysconfig/network | |
20 | ||
21 | pidfile=/var/run/php/fpm.pid | |
22 | ||
23 | start() { | |
24 | # Check if the service is already running? | |
25 | if [ ! -f /var/lock/subsys/php-fpm ]; then | |
26 | msg_starting "PHP FastCGI Process Manager" | |
1d2cd258 | 27 | daemon --pidfile $pidfile /usr/sbin/php-fpm --fpm-config /etc/php/php-fpm.conf |
0fc91222 ER |
28 | RETVAL=$? |
29 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/php-fpm | |
30 | else | |
31 | msg_already_running "PHP FastCGI Process Manager" | |
32 | fi | |
33 | } | |
34 | ||
35 | stop() { | |
36 | if [ -f /var/lock/subsys/php-fpm ]; then | |
37 | # Stop daemons. | |
38 | msg_stopping "PHP FastCGI Process Manager" | |
39 | # always gracefully shut down php-fpm | |
40 | /sbin/start-stop-daemon -q --stop -s QUIT --retry QUIT/600/TERM/10 --pidfile $pidfile | |
41 | [ "$?" -eq 0 ] && ok || fail | |
42 | rm -f /var/lock/subsys/php-fpm | |
43 | else | |
44 | msg_not_running "PHP FastCGI Process Manager" | |
45 | fi | |
46 | } | |
47 | ||
48 | reload() { | |
49 | local sig=${1:-HUP} | |
50 | local retnr=${2:-7} | |
51 | if [ -f /var/lock/subsys/php-fpm ]; then | |
52 | msg_reloading "PHP FastCGI Process Manager" | |
53 | killproc --pidfile $pidfile php-fpm -$sig | |
54 | RETVAL=$? | |
55 | else | |
56 | msg_not_running "PHP FastCGI Process Manager" | |
57 | RETVAL=$retnr | |
58 | fi | |
59 | } | |
60 | ||
61 | condrestart() { | |
62 | if [ -f /var/lock/subsys/php-fpm ]; then | |
63 | stop | |
64 | start | |
65 | else | |
66 | msg_not_running "PHP FastCGI Process Manager" | |
67 | RETVAL=$1 | |
68 | fi | |
69 | } | |
70 | ||
71 | RETVAL=0 | |
72 | # See how we were called. | |
73 | case "$1" in | |
74 | start) | |
75 | start | |
76 | ;; | |
77 | stop|quit) | |
78 | stop | |
79 | ;; | |
80 | restart) | |
81 | stop | |
82 | start | |
83 | ;; | |
84 | try-restart) | |
85 | condrestart 0 | |
86 | ;; | |
87 | reload|force-reload) | |
88 | reload USR2 7 | |
89 | ;; | |
90 | flush-logs|logrotate) | |
91 | reload USR1 0 | |
92 | ;; | |
93 | status) | |
6a65c24a | 94 | status php-fpm |
0fc91222 ER |
95 | RETVAL=$? |
96 | ;; | |
97 | *) | |
98 | msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|flush-logs|status}" | |
99 | exit 3 | |
100 | ;; | |
101 | esac | |
102 | ||
103 | exit $RETVAL |