]>
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" | |
2fce3139 | 27 | daemon --pidfile $pidfile /usr/bin/php.fpm --fpm --fpm-config /etc/php/fpm.conf |
2a6ec4b9 ER |
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 |
2fce3139 ER |
40 | /sbin/start-stop-daemon -q --stop -s QUIT --retry QUIT/600/TERM/10 --pidfile $pidfile |
41 | [ "$?" -eq 0 ] && ok || fail | |
2a6ec4b9 | 42 | rm -f /var/lock/subsys/php-fpm |
ae1427a4 | 43 | else |
2a6ec4b9 | 44 | msg_not_running "PHP FastCGI Process Manager" |
ae1427a4 ER |
45 | fi |
46 | } | |
3aa45803 | 47 | |
ae1427a4 | 48 | reload() { |
2a6ec4b9 ER |
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 | |
ae1427a4 | 58 | fi |
ae1427a4 | 59 | } |
3aa45803 | 60 | |
ae1427a4 ER |
61 | condrestart() { |
62 | if [ -f /var/lock/subsys/php-fpm ]; then | |
63 | stop | |
64 | start | |
65 | else | |
2a6ec4b9 | 66 | msg_not_running "PHP FastCGI Process Manager" |
ae1427a4 ER |
67 | RETVAL=$1 |
68 | fi | |
69 | } | |
3aa45803 | 70 | |
ae1427a4 ER |
71 | RETVAL=0 |
72 | # See how we were called. | |
73 | case "$1" in | |
74 | start) | |
75 | start | |
3aa45803 | 76 | ;; |
04aad4ba | 77 | stop|quit) |
ae1427a4 ER |
78 | stop |
79 | ;; | |
80 | restart) | |
81 | stop | |
82 | start | |
83 | ;; | |
84 | try-restart) | |
85 | condrestart 0 | |
86 | ;; | |
87 | reload|force-reload) | |
2a6ec4b9 | 88 | reload USR2 7 |
ae1427a4 | 89 | ;; |
ae1427a4 | 90 | flush-logs|logrotate) |
2a6ec4b9 | 91 | reload USR1 0 |
ae1427a4 ER |
92 | ;; |
93 | status) | |
94 | status php-fpm php.fpm | |
95 | RETVAL=$? | |
96 | ;; | |
97 | *) | |
98 | msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|flush-logs|status}" | |
99 | exit 3 | |
3aa45803 | 100 | ;; |
3aa45803 | 101 | esac |
ae1427a4 ER |
102 | |
103 | exit $RETVAL |