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