SOURCES: lighttpd.init - "reload" will just reopen logs, so move "...

glen glen at pld-linux.org
Tue Jan 10 19:58:05 CET 2006


Author: glen                         Date: Tue Jan 10 18:58:05 2006 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- "reload" will just reopen logs, so move "graceful" where "restart" is
- check config before bringing webserver down, to prevent downtime due broken config

---- Files affected:
SOURCES:
   lighttpd.init (1.6 -> 1.7) 

---- Diffs:

================================================================
Index: SOURCES/lighttpd.init
diff -u SOURCES/lighttpd.init:1.6 SOURCES/lighttpd.init:1.7
--- SOURCES/lighttpd.init:1.6	Wed Dec 21 02:00:51 2005
+++ SOURCES/lighttpd.init	Tue Jan 10 19:57:59 2006
@@ -26,6 +26,17 @@
 	exit 0
 fi
 
+configtest() {
+	out=`env SHELL=/bin/sh lighttpd -t -f /etc/lighttpd/lighttpd.conf $HTTPD_OPTS 2>&1`
+	rc=$?
+	if [ "$rc" = 0 ]; then
+		return
+	fi
+	echo >&2 ""
+	echo >&2 "$out"
+	fail
+}
+
 RETVAL=0
 # See how we were called.
 case "$1" in
@@ -33,6 +44,7 @@
 	# Check if the service is already running?
 	if [ ! -f /var/lock/subsys/lighttpd ]; then
 		msg_starting lighttpd
+		configtest || exit 1
 		daemon env SHELL=/bin/sh lighttpd -f /etc/lighttpd/lighttpd.conf $HTTPD_OPTS
 		RETVAL=$?
 		[ $RETVAL -eq 0 ] && touch /var/lock/subsys/lighttpd
@@ -54,9 +66,10 @@
 	status lighttpd
 	RETVAL=$?
 	;;
-  restart)
+  restart|graceful)
 	if [ -f /var/lock/subsys/lighttpd ]; then
 		msg_stopping lighttpd
+		configtest || exit 1
 		# sending INT signal will make lighttpd close all listening sockets and
 		# wait for client connections to terminate.
 		killproc --pidfile /var/run/lighttpd.pid lighttpd -INT
@@ -64,9 +77,11 @@
 	fi
 	$0 start
 	;;
-  reload|force-reload|graceful)
+  reload|force-reload)
+	# this is not reload. it will just reopen logs
 	if [ -f /var/lock/subsys/lighttpd ]; then
 		msg_reloading lighttpd
+		configtest || exit 1
 		killproc --pidfile /var/run/lighttpd.pid lighttpd -HUP
 		RETVAL=$?
 	else
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/SOURCES/lighttpd.init?r1=1.6&r2=1.7&f=u



More information about the pld-cvs-commit mailing list