Project

General

Profile

Actions

ScriptsUbuntu » History » Revision 2

« Previous | Revision 2/11 (diff) | Next »
icy, 2008-04-05 17:33
renamed fcgi user and group, ip vars


{{{
#!/bin/sh

PATH=/sbin:/bin:/usr/sbin:/usr/bin
LIGHTY_DAEMON=/usr/sbin/lighttpd
LIGHTY_OPTS="-f /etc/lighttpd/lighttpd.conf"
LIGHTY_NAME=lighttpd
LIGHTY_PIDFILE=/var/run/$LIGHTY_NAME.pid
SCRIPTNAME=/etc/init.d/$LIGHTY_NAME
SSD="/sbin/start-stop-daemon"
PHP_FCGI_CHILDREN=10
PHP_FCGI_MAX_REQUESTS=1000
RETVAL=0

FCGI_USER=lighttpd
FCGI_GROUP=lighttpd
FCGI_DAEMON="/usr/bin/spawn-fcgi"
FCGI_PROGRAM="/usr/bin/php-cgi"
#FCGI_IP="127.0.0.1"
#FCGI_PORT="4050"
FCGI_SOCKET="/tmp/php-fastcgi.sock"
FCGI_PIDFILE="/var/run/spawn-fcgi.pid"

test -x $LIGHTY_DAEMON || exit 0

set -e

export PHP_FCGI_CHILDREN PHP_FCGI_MAX_REQUESTS FCGI_WEB_SERVER_ADDRS

. /lib/lsb/init-functions

case "$1" in
start)
log_daemon_msg "Starting $LIGHTY_NAME"
if ! $SSD --quiet --start --pidfile $LIGHTY_PIDFILE --exec $LIGHTY_DAEMON -- $LIGHTY_OPTS 2> /dev/null; then
log_end_msg 1
else
log_end_msg 0
fi
log_daemon_msg "Starting spawn-fcgi"
if ! $FCGI_DAEMON s $FCGI_SOCKET -f $FCGI_PROGRAM -u $FCGI_USER -g $FCGI_GROUP -C $PHP_FCGI_CHILDREN -P $FCGI_PIDFILE 2> /dev/null; then
log_end_msg 1
else
log_end_msg 0
fi
RETVAL=$?
;;
stop)
log_daemon_msg "Stopping $LIGHTY_NAME"
if $SSD --quiet --stop --oknodo --retry 30 --signal 2 --exec $LIGHTY_DAEMON; then
rm -f $LIGHTY_PIDFILE $FCGI_PIDFILE $FCGI_SOCKET
log_end_msg 0
else
log_end_msg 1
fi
log_daemon_msg "Killing all spawn-fcgi processes"
if killall --signal 2 php-cgi > /dev/null 2> /dev/null; then
log_end_msg 0
else
log_end_msg 1
fi
RETVAL=$?
;;
reload)
log_daemon_msg "Reloading $LIGHTY_NAME configuration"
if $SSD --stop --signal 2 --oknodo --retry 30 --quiet --pidfile $LIGHTY_PIDFILE --exec $LIGHTY_DAEMON; then
if $SSD --start --quiet --pidfile $LIGHTY_PIDFILE --exec $LIGHTY_DAEMON -
$LIGHTY_OPTS ; then
log_end_msg 0
else
log_end_msg 1
fi
else
log_end_msg 1
fi
RETVAL=$?
;;
restart|force-reload)
$0 stop
[ -r $LIGHTY_PIDFILE ] && while pidof lighttpd |\
grep -q `cat $LIGHTY_PIDFILE 2>/dev/null` 2>/dev/null ; do sleep 1; done
$0 start
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
exit 1
;;
esac

exit $RETVAL
}}}

Updated by icy almost 12 years ago · 2 revisions