ServerSetup: spawn-fcgi-php

File spawn-fcgi-php, 1.7 kB (added by faisal, 15 years ago)

spawn fcgi init script

Line 
1#! /bin/sh
2
3### BEGIN INIT INFO
4# Provides:          php-cgi
5# Required-Start:    $local_fs $remote_fs $network $syslog
6# Required-Stop:     $local_fs $remote_fs $network $syslog
7# Default-Start:     2 3 4 5
8# Default-Stop:      0 1 6
9# Short-Description: spawns the php-cgi
10# Description:       spawns the php-cgi
11### END INIT INFO
12
13PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
14NAME=php-cgi
15DESC=php-cgi
16
17test -x $DAEMON || exit 0
18
19PIDFILE="/var/run/$NAME.pid"
20DAEMON="/usr/bin/php-cgi"
21SPAWN_FCGI="/usr/bin/spawn-fcgi"
22FCGI_PORT=9000
23FCGI_USER="www-data"
24FCGI_GROUP="www-data"
25FCGI_CHILDREN=4
26
27PHP_FCGI_MAX_REQUESTS=1000
28export PHP_FCGI_MAX_REQUESTS
29
30# Include php-cgi defaults if available
31if [ -f /etc/default/php-cgi ] ; then
32        . /etc/default/php-cgi
33fi
34
35SPAWN_FCGI_OPTS="-f $DAEMON -a 127.0.0.1 -p $FCGI_PORT -u $FCGI_USER -g $FCGI_GROUP -C $FCGI_CHILDREN -P $PIDFILE"
36
37set -e
38
39. /lib/lsb/init-functions
40
41case "$1" in
42  start)
43        echo -n "Starting $DESC: "
44        start-stop-daemon --start --quiet --pidfile $PIDFILE --exec "$SPAWN_FCGI" -- $SPAWN_FCGI_OPTS || true
45        echo "$NAME."
46        ;;
47  stop)
48        echo -n "Stopping $DESC: "
49        start-stop-daemon --stop --quiet --pidfile $PIDFILE --exec "$DAEMON" || true
50        echo "$NAME."
51        ;;
52  restart)
53        echo -n "Restarting $DESC: "
54        start-stop-daemon --stop --quiet --pidfile $PIDFILE --exec "$DAEMON" || true
55        sleep 1
56        start-stop-daemon --start --quiet --pidfile $PIDFILE --exec "$SPAWN_FCGI" -- $SPAWN_FCGI_OPTS || true
57        echo "$NAME."
58        ;;
59  status)
60        status_of_proc -p $PIDFILE "$DAEMON" php-cgi && exit 0 || exit $?
61        ;;
62  *)
63        echo "Usage: $NAME {start|stop|restart|status}" >&2
64        exit 1
65        ;;
66esac
67
68exit 0