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