From 085d70d77eb82a735dee9b305cb49251ade80259 Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Mon, 6 Aug 2012 07:15:16 -0500 Subject: [PATCH] Fix gerritbot init status checking. The logic is lifted from apache, but changed to use ps instead of pidof, since gerritbot runs as a python program, so pidof doesn't work. Change-Id: I504e3534b55dfc27b09d7f044169b2f3a18dcd36 Reviewed-on: https://review.openstack.org/10881 Reviewed-by: James E. Blair Reviewed-by: Clark Boylan Approved: Monty Taylor Tested-by: Jenkins --- modules/gerritbot/files/gerritbot.init | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/modules/gerritbot/files/gerritbot.init b/modules/gerritbot/files/gerritbot.init index 788e54e0f2..7b9ce7db52 100755 --- a/modules/gerritbot/files/gerritbot.init +++ b/modules/gerritbot/files/gerritbot.init @@ -36,6 +36,17 @@ USER=gerrit2 # Depend on lsb-base (>= 3.0-6) to ensure that this file is present. . /lib/lsb/init-functions +pidof_gerritbot() { + # if there is actually an gerritbot process whose pid is in PIDFILE, + # print it and return 0. + if [ -e "$PIDFILE" ]; then + if ps -ef | grep gerrit[b]ot | grep python | awk '{print $2}' | grep -w $(cat $PIDFILE); then + return 0 + fi + fi + return 1 +} + # # Function that starts the daemon/service # @@ -106,8 +117,19 @@ case "$1" in esac ;; status) - status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $? - ;; + PID=$(pidof_gerritbot) || true + if [ -n "$PID" ]; then + log_daemon_msg "$DESC is running (pid $PID)." + exit 0 + else + log_daemon_msg "$DESC is NOT running." + if [ -e "$PIDFILE" ]; then + exit 1 + else + exit 3 + fi + fi + ;; #reload|force-reload) # # If do_reload() is not implemented then leave this commented out