]> git.pld-linux.org Git - packages/lighttpd.git/commitdiff
- "reload" will just reopen logs, so move "graceful" where "restart" is
authorElan Ruusamäe <glen@pld-linux.org>
Tue, 10 Jan 2006 18:57:59 +0000 (18:57 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
- check config before bringing webserver down, to prevent downtime due broken config

Changed files:
    lighttpd.init -> 1.7

lighttpd.init

index 9a1d98723fa32bd455fd5db10d933262c0650e09..e20559144bd425de0b6d8a26d3757f8206a09099 100644 (file)
@@ -26,6 +26,17 @@ else
        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 @@ case "$1" in
        # 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 @@ case "$1" in
        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 @@ case "$1" in
        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
This page took 0.192049 seconds and 4 git commands to generate.