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