From 9d9ea1ed24635c24611555923f217bdf3dd73d33 Mon Sep 17 00:00:00 2001 From: Dan Voiculeasa Date: Thu, 17 Jun 2021 17:36:37 +0300 Subject: [PATCH] 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 Change-Id: Ia77988ce282ea17de84b89e833ec686df342b3c4 (cherry picked from commit 4d5c6c7f21f3b44bd2ec7c55c820a5242384198d) --- fm-rest-api/fm/scripts/fm-api | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/fm-rest-api/fm/scripts/fm-api b/fm-rest-api/fm/scripts/fm-api index bf685411..2d5109ab 100644 --- a/fm-rest-api/fm/scripts/fm-api +++ b/fm-rest-api/fm/scripts/fm-api @@ -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 + 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 running" - return 0 + 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 }