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 <corvus@inaugust.com>
Reviewed-by: Clark Boylan <clark.boylan@gmail.com>
Approved: Monty Taylor <mordred@inaugust.com>
Tested-by: Jenkins
This commit is contained in:
Monty Taylor 2012-08-06 07:15:16 -05:00 committed by Jenkins
parent 993f7c5f78
commit 085d70d77e

View File

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