From 61fdfa3252d6f5a26adbd088a2614bdcc8f7c802 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Pawe=C5=82=20Go=C5=82aszewski?= Date: Wed, 9 Dec 2009 15:43:31 +0000 Subject: [PATCH] - make optional lighttpd-angel support (supervisor and HUP handler) Changed files: lighttpd.init -> 1.15 lighttpd.spec -> 1.318 lighttpd.sysconfig -> 1.4 --- lighttpd.init | 40 ++++++++++++++++++++++++++++++++-------- lighttpd.spec | 2 +- lighttpd.sysconfig | 5 +++++ 3 files changed, 38 insertions(+), 9 deletions(-) diff --git a/lighttpd.init b/lighttpd.init index f855d78..43c1954 100644 --- a/lighttpd.init +++ b/lighttpd.init @@ -68,7 +68,13 @@ start() { checkconfig msg_starting "Lighttpd Web Server"; busy - env SHELL=/bin/sh lighttpd -f /etc/lighttpd/lighttpd.conf $HTTPD_OPTS + if is_yes "${LIGHT_ANGEL}"; then + daemon --fork --pidfile /var/run/lighttpd-angel.pid --makepid \ + env SHELL=/bin/sh lighttpd-angel -D -f /etc/lighttpd/lighttpd.conf $HTTPD_OPTS 1>&2 + + else + env SHELL=/bin/sh lighttpd -f /etc/lighttpd/lighttpd.conf $HTTPD_OPTS + fi RETVAL=$? if [ $RETVAL -eq 0 ]; then ok @@ -88,15 +94,23 @@ stop() { msg_stopping "Lighttpd Web Server" killproc --pidfile /var/run/lighttpd.pid lighttpd rm -f /var/lock/subsys/lighttpd >/dev/null 2>&1 + rm -f /var/run/lighttpd*.pid >/dev/null 2>&1 } restart() { local pid # short circuit to safe reload if pid exists and is alive - if [ -f /var/lock/subsys/lighttpd ] && pid=$(pidofproc lighttpd lighttpd.pid) && checkpid $pid; then - reload - return + if is_yes "${LIGHT_ANGEL}"; then + if [ -f /var/lock/subsys/lighttpd ] && pid=$(pidofproc lighttpd-angel lighttpd-angel.pid) && checkpid $pid; then + reload + return + fi + else + if [ -f /var/lock/subsys/lighttpd ] && pid=$(pidofproc lighttpd lighttpd.pid) && checkpid $pid; then + reload + return + fi fi checkconfig @@ -105,6 +119,7 @@ restart() { } reload() { + # TODO: check if process is running. Start it in this case. if [ ! -f /var/lock/subsys/lighttpd ]; then msg_not_running "Lighttpd Web Server" RETVAL=7 @@ -114,10 +129,17 @@ reload() { checkconfig msg_reloading "Lighttpd Web Server" - # 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 - env SHELL=/bin/sh lighttpd -f /etc/lighttpd/lighttpd.conf $HTTPD_OPTS + if is_yes "${LIGHT_ANGEL}"; then + # sending HUP signal to angel will make lighttpd close all listening + # sockets and wait for client connections to terminate. After that new + # child will be started + killproc lighttpd-angel -HUP + else + # 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 + env SHELL=/bin/sh lighttpd -f /etc/lighttpd/lighttpd.conf $HTTPD_OPTS + fi RETVAL=$? } @@ -141,6 +163,7 @@ flush-logs() { fi show "Rotating %s logs" lighttpd + # send HUP to main lighttpd (not angel) process to rotate logs: killproc --pidfile /var/run/lighttpd.pid lighttpd -HUP RETVAL=$? } @@ -170,6 +193,7 @@ case "$1" in checkconfig 1 ;; status) + status lighttpd-angel status lighttpd RETVAL=$? ;; diff --git a/lighttpd.spec b/lighttpd.spec index d59498b..3ae1ce0 100644 --- a/lighttpd.spec +++ b/lighttpd.spec @@ -23,7 +23,7 @@ Summary: Fast and light HTTP server Summary(pl.UTF-8): Szybki i lekki serwer HTTP Name: lighttpd Version: 1.4.25 -Release: 2 +Release: 2.1 License: BSD Group: Networking/Daemons/HTTP Source0: http://download.lighttpd.net/lighttpd/releases-1.4.x/%{name}-%{version}.tar.bz2 diff --git a/lighttpd.sysconfig b/lighttpd.sysconfig index aba3188..df153ac 100644 --- a/lighttpd.sysconfig +++ b/lighttpd.sysconfig @@ -3,6 +3,11 @@ # Define nice level for lighttpd #SERVICE_RUN_NICE_LEVEL="+0" +# Use lighttpd-angel +# Allows gracefull restart and crash recovery. +# Off by default but consider enabling +#LIGHT_ANGEL="yes" + # Give it 4096 fd's. #SERVICE_LIMITS="$DEFAULT_SERVICE_LIMITS -n 4096" -- 2.44.0