Date: Sunday, August 7, 2011 @ 06:50:50
  Author: pierre
Revision: 134666

Fix FS#25430

* We need to save the pid of lighttpd-angel as lighttpd only save the child's 
pid
* Add gracefull-stop to rc script

Modified:
  lighttpd/trunk/PKGBUILD
  lighttpd/trunk/lighttpd.conf
  lighttpd/trunk/lighttpd.rc.d

---------------+
 PKGBUILD      |    6 +++---
 lighttpd.conf |    1 -
 lighttpd.rc.d |   38 ++++++++++++++++++++++----------------
 3 files changed, 25 insertions(+), 20 deletions(-)

Modified: PKGBUILD
===================================================================
--- PKGBUILD    2011-08-07 10:26:45 UTC (rev 134665)
+++ PKGBUILD    2011-08-07 10:50:50 UTC (rev 134666)
@@ -3,7 +3,7 @@
 
 pkgname=lighttpd
 pkgver=1.4.29
-pkgrel=1
+pkgrel=2
 pkgdesc='a secure, fast, compliant and very flexible web-server'
 license=('custom')
 arch=('i686' 'x86_64')
@@ -19,9 +19,9 @@
 
source=("http://download.lighttpd.net/lighttpd/releases-1.4.x/lighttpd-${pkgver}.tar.bz2";
         'lighttpd.rc.d' 'lighttpd.logrotate.d' 'lighttpd.conf')
 md5sums=('e6e67b09986cb504db630b5a86b2dd76'
-         '369f2eea6231342b514ca4777bf395c8'
+         '268386e71f5748dc1d887b9a0ab65589'
          '913e2157fa78d990c32146f387d44c2b'
-         '2803a9ee7f20409c69f1566d2d90720e')
+         'acdaa94299e6299cb5085e6d88babeca')
 
 build() {
        cd $srcdir/$pkgname-$pkgver

Modified: lighttpd.conf
===================================================================
--- lighttpd.conf       2011-08-07 10:26:45 UTC (rev 134665)
+++ lighttpd.conf       2011-08-07 10:50:50 UTC (rev 134666)
@@ -6,7 +6,6 @@
 server.username                = "http"
 server.groupname       = "http"
 server.document-root   = "/srv/http"
-server.pid-file                = "/var/run/lighttpd/lighttpd.pid"
 server.errorlog                = "/var/log/lighttpd/error.log"
 dir-listing.activate   = "enable"
 index-file.names       = ( "index.html" )

Modified: lighttpd.rc.d
===================================================================
--- lighttpd.rc.d       2011-08-07 10:26:45 UTC (rev 134665)
+++ lighttpd.rc.d       2011-08-07 10:50:50 UTC (rev 134666)
@@ -4,24 +4,13 @@
 . /etc/rc.d/functions
 
 
-get_pid_file() {
-       /usr/sbin/lighttpd -p -f /etc/lighttpd/lighttpd.conf 2>/dev/null | grep 
server.pid-file | sed -E 's/.*"(.+)"/\1/'
-}
+pid_file='/var/run/lighttpd/lighttpd-angel.pid'
 
 get_pid() {
-       local pid_file=$(get_pid_file)
-       local pid=$(pidof -o %PPID lighttpd-angel)
-       # only needed when updating from 1.4.26
-       # TODO: remove in future versions
-       local old_pid=$(pidof -o %PPID lighttpd)
        if [ -r "${pid_file}" ]; then
                cat "${pid_file}"
-       elif [ -n "${pid}" ]; then
-               echo "${pid}"
-       elif [ -n "${old_pid}" ]; then
-               echo "${old_pid}"
        else
-               echo ''
+               pgrep -f /usr/sbin/lighttpd-angel
        fi
 }
 
@@ -43,7 +32,7 @@
                stat_die
        fi
 
-       local piddir=$(dirname "$(get_pid_file)")
+       local piddir=$(dirname "${pid_file}")
        if [ ! -d "${piddir}" ]; then
                install -d -m755 -o http -g http "${piddir}"
        fi
@@ -60,6 +49,7 @@
                if [ $? -gt 0 ]; then
                        stat_die
                else
+                       echo $! > "${pid_file}"
                        add_daemon lighttpd
                        stat_done
                fi
@@ -75,13 +65,25 @@
        if [ $? -gt 0 ]; then
                stat_fail
        else
-               local pid_file=$(get_pid_file)
                [ -f "${pid_file}" ] && rm -f "${pid_file}"
                rm_daemon lighttpd
                stat_done
        fi
 }
 
+gracefull-stop() {
+       stat_busy 'Stopping lighttpd gracefully'
+       local PID=$(get_pid)
+       [ -n "$PID" ] && kill -INT $PID &> /dev/null
+       if [ $? -gt 0 ]; then
+               stat_fail
+       else
+               [ -f "${pid_file}" ] && rm -f "${pid_file}"
+               rm_daemon lighttpd
+               stat_done
+       fi
+}
+
 reload() {
        stat_busy 'Reloading lighttpd'
        local PID=$(get_pid)
@@ -103,6 +105,10 @@
                test_config
                stop
                ;;
+       gracefull-stop)
+               test_config
+               stop
+               ;;
        reload)
                test_config
                reload
@@ -120,7 +126,7 @@
                ck_status lighttpd
                ;;
        *)
-       echo "usage: $0 {start|stop|reload|restart|status}"
+       echo "usage: $0 {start|stop|gracefull-stop|reload|restart|status}"
 esac
 
 exit 0

Reply via email to