#! /bin/sh # # php-fcgi This start-stop file fires up the PHP-FCGI handlers for # lighttpd and stops them by terminating and waiting for # them to exit # # by Torsten Koester (torsten@jserver.de) # # Version: 0.1 -- tbk 2005-11-07 # PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DAEMON=/etc/lighttpd/spawn-php.sh PHP_FCGI_BINARY=/usr/local/php5-fcgi/bin/php PHP_FCGI_PORT=1026 NAME=php-fcgi DESC="php-fcgi" test -x $DAEMON || exit 0 set -e case "$1" in start) echo "Starting $NAME ..." start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \ --exec $DAEMON ;; stop) # Checking whether PHP is running or not if [ `ps auxw | grep -v grep | grep $PHP_FCGI_BINARY | wc -l` != 0 ] then echo -n "Stopping $NAME. This may take a while ." killall "$PHP_FCGI_BINARY" # As some instances may need time to be killed, # we'll check every few seconds if the killing # was successfull while [ `netstat -a | grep $PHP_FCGI_PORT | wc -l` != 0 ]; do sleep 1 echo -n "." done echo " done." fi ;; restart|force-reload) # # If the "reload" option is implemented, move the "force-reload" # option to the "reload" entry above. If not, "force-reload" is # just the same as "restart". # echo "Restarting $NAME ..." /etc/init.d/$NAME stop /etc/init.d/$NAME start # Notify Lighttpd of new PHP daemon echo "Restarting Lighttpd to notify about new PHP instances ..." /etc/init.d/lighttpd restart ;; *) N=/etc/init.d/$NAME echo "Usage: $N {start|stop|restart|force-reload}" >&2 exit 1 ;; esac exit 0