forked from cds-snc/notification-api
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Squash 2041 - Try Kyle's updated script for healthcheck
- Loading branch information
1 parent
5b49d6a
commit f17fb56
Showing
1 changed file
with
9 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,14 @@ | ||
#!/bin/sh | ||
#! /bin/sh | ||
|
||
set -e | ||
|
||
function get_celery_pids { | ||
# get the PIDs of the process whose parent is the main celery process, saved in celery.pid | ||
# print only pid and their command, get the ones with "celery" in their name | ||
# and keep only these PIDs | ||
grep_string="run_celery.notify_celery\ worker" | ||
celery_pid_count=$(ps aux | grep -E run_celery.notify_celery\ worker | grep -v grep | wc -l) | ||
|
||
set +o pipefail # so grep returning no matches does not premature fail pipe | ||
APP_PIDS=$(pstree -p `cat /tmp/celery.pid` | sed 's/\(.*\)-celery(\(\d*\))/\2/') | ||
echo "Here are the APP_PIDS: ${APP_PIDS}" | ||
set -o pipefail # pipefail should be set everywhere else | ||
} | ||
|
||
function ensure_celery_is_running { | ||
if [ "${APP_PIDS}" = "" ]; then | ||
echo "There are no celery processes running, this container is bad" | ||
exit 1 | ||
fi | ||
|
||
for APP_PID in ${APP_PIDS}; do | ||
kill -0 ${APP_PID} 2&>/dev/null || return 1 | ||
done | ||
} | ||
|
||
get_celery_pids | ||
|
||
ensure_celery_is_running | ||
if [ $celery_pid_count -ne 17 ]; then | ||
echo -e "There are an incorrect number of Celery PIDs: $celery_pid_count" | ||
exit 1 | ||
else | ||
echo "Celery health check okay" | ||
fi |