]>
Commit | Line | Data |
---|---|---|
7d4d1b66 JP |
1 | #!/bin/sh |
2 | # | |
3 | # Created 2010-09-26 by presbrey@mit.edu | |
4 | # | |
5 | # php This shell script takes care of starting and stopping PHP | |
6 | # | |
7 | # chkconfig: - 80 30 | |
8 | # description: manages PHP spawned in FastCGI mode with spawn-fcgi | |
9 | # processname: php-cgi | |
10 | # config: /etc/php.ini | |
11 | ||
12 | ||
13 | # Source function library | |
14 | if [ -f /etc/rc.d/init.d/functions ]; then | |
15 | . /etc/rc.d/init.d/functions | |
16 | elif [ -f /etc/init.d/functions ]; then | |
17 | . /etc/init.d/functions | |
18 | elif [ -f /etc/rc.d/functions ]; then | |
19 | . /etc/rc.d/functions | |
20 | fi | |
21 | ||
22 | pidfile=${PIDFILE-/var/run/php.pid} | |
23 | lockfile=${LOCKFILE-/var/lock/subsys/php} | |
24 | PHP_BIN=/usr/bin/php-cgi | |
25 | PHP_SOCK=/tmp/php.sock | |
26 | PHP_USER=lighttpd | |
27 | PHP_GROUP=apache | |
28 | PHP_CHILDREN=8 | |
29 | ||
30 | # Read configuration (environment etc.) | |
31 | if [ -f /etc/sysconfig/php ]; then | |
32 | . /etc/sysconfig/php | |
33 | fi | |
34 | ||
35 | RETVAL=0 | |
36 | ||
37 | # See how we were called. | |
38 | case "$1" in | |
39 | start) | |
40 | # Start daemons. | |
41 | echo -n "Starting php: " | |
42 | daemon --pidfile=${pidfile} spawn-fcgi -C $PHP_CHILDREN -f $PHP_BIN -u $PHP_USER -g $PHP_GROUP -s $PHP_SOCK -P $pidfile | |
43 | RETVAL=$? | |
44 | echo | |
45 | [ $RETVAL = 0 ] && touch ${lockfile} | |
46 | ;; | |
47 | stop) | |
48 | # Stop daemons. | |
49 | echo -n "Stopping php: " | |
50 | killproc -p ${pidfile} -d 1 $PID_BIN -9 | |
51 | RETVAL=$? | |
52 | echo | |
53 | [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile} | |
54 | ;; | |
55 | restart) | |
56 | $0 stop | |
57 | $0 start | |
58 | ;; | |
59 | status) | |
60 | status -p $pidfile $PHP_BIN | |
61 | RETVAL=$? | |
62 | ;; | |
63 | *) | |
64 | echo "Usage: php {start|stop|restart|reload|status}" | |
65 | RETVAL=2 | |
66 | esac | |
67 | ||
68 | exit $RETVAL |