Fix fm-api service startup

The fm-api service is not properly started since the status logic is
wrong.

Updated the status logic to drop the regex approach and use the PIDFILE
instead.

There is a confirm_stop logic step which still needs to use the regex
approach because the main process spawns children. Updated the regex
for confirm_stop logic step. Now looking for /usr/bin/pythton3 and
/usr/libexec/platform-python.

Story: 2008454
Task: 42631
Depends-On: I970c2600475e32f2c5fb815738a2fe79f99a5b17
Signed-off-by: Dan Voiculeasa <dan.voiculeasa@windriver.com>
Change-Id: Ia77988ce282ea17de84b89e833ec686df342b3c4
(cherry picked from commit 4d5c6c7f21)
This commit is contained in:
Dan Voiculeasa 2021-06-17 17:36:37 +03:00 committed by Chuck Short
parent 6f4cb036f3
commit 9d9ea1ed24
1 changed files with 10 additions and 13 deletions

View File

@ -39,18 +39,15 @@ export PATH
status()
{
# Status function has a standard set of return codes to indicate daemon status
# http://refspecs.linuxbase.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html
local my_processes=`pgrep -l -f "^(python|/usr/bin/python|/usr/bin/python2|/usr/bin/python3) ${DAEMON}([^\w-]|$)"`
if [ -z "${my_processes}" ]; then
echo "$NAME is not running"
return 1
fi
pid=`cat $PIDFILE 2>/dev/null`
if [ -n "$pid" ]; then
if ps -p $pid | grep $NAME &> /dev/null ; then
echo "$NAME is running"
return 0
fi
fi
echo "$NAME is not running"
return 1
}
start ()
@ -82,12 +79,12 @@ start ()
confirm_stop()
{
local my_processes=`pgrep -l -f "^(python|/usr/bin/python|/usr/bin/python2|/usr/bin/python3) ${DAEMON}([^\w-]|$)"`
local my_processes=`pgrep -l -f "^(python|/usr/bin/python|/usr/bin/python2|/usr/bin/python3|/usr/libexec/platform-python) ${DAEMON}([^\w-]|$)"`
if [ -n "${my_processes}" ]
then
logger -t $NAME "About to SIGKILL the following: ${my_processes}"
pkill -KILL -f "^(python|/usr/bin/python|/usr/bin/python2) ${DAEMON}([^\w-]|$)"
pkill -KILL -f "^(python|/usr/bin/python|/usr/bin/python2|/usr/bin/python3|/usr/libexec/platform-python) ${DAEMON}([^\w-]|$)"
fi
}