Fix the lighttpd process recovery failure

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 <tao.liu@windriver.com>
This commit is contained in:
Tao Liu 2019-10-07 22:15:26 -04:00
parent fbc09b8db8
commit 66d88788a8
1 changed files with 9 additions and 5 deletions

View File

@ -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