From 66d88788a8bc85e8b627ae44f8c5aca85e45d473 Mon Sep 17 00:00:00 2001 From: Tao Liu Date: Mon, 7 Oct 2019 22:15:26 -0400 Subject: [PATCH] Fix the lighttpd process recovery failure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the lighttpd starts without creating a pid file, SM will restart the process after the audit detects the failure. The init script then kills the current running process and starts a new one. The kill method was using the default port 80, as a result the process that was running without a pid file was not killed. Therefore, ‘Service group web-services degraded’ alarm was never cleared due to recovery failure. This update changes the kill method to kill the process that running on the configured lighttpd port. Change-Id: Id6cae43e315d0def771b9f1422fc7753d57e6710 Closes-Bug: 1844456 Signed-off-by: Tao Liu --- lighttpd-config/files/lighttpd.init | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lighttpd-config/files/lighttpd.init b/lighttpd-config/files/lighttpd.init index 256e950..3d347e5 100755 --- a/lighttpd-config/files/lighttpd.init +++ b/lighttpd-config/files/lighttpd.init @@ -16,18 +16,22 @@ NAME=lighttpd DESC="Lighttpd Web Server" OPTS="-f /etc/lighttpd/lighttpd.conf" PIDFILE="/var/run/$NAME.pid" -PORT="80" start() { - if lsof -t -i:${PORT} 1> /dev/null 2>&1; then - kill $(lsof -t -i:${PORT}) > /dev/null 2>&1 + port=$(cat /etc/lighttpd/lighttpd.conf | awk '{if ($1 == "server.port") + { print $3; }}') + if [ ! -z "$port" ]; then + pid=$(lsof -t -i:${port} 2> /dev/null) + if [ ! -z "$pid" ]; then + kill ${pid} > /dev/null 2>&1 + fi fi if [ -e $PIDFILE ]; then - PIDDIR=/proc/$(cat $PIDFILE) - if [ -d ${PIDDIR} ]; then + pid=$(pidof $NAME 2> /dev/null) + if [ -n "$pid" ]; then echo "$DESC already running." return else