-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
20 additions
and
23 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
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,33 +1,30 @@ | ||
# Checks health by checking worker process is running along with connectivity checks of SQS and Postgres | ||
|
||
# Prevent exit on error code | ||
set -e | ||
|
||
# Check Celery process is running | ||
pgrep celery | ||
#pgrep celery > /dev/null 2> /dev/null | ||
|
||
pgrep celery > /dev/null 2> /dev/null | ||
exit_code=$? | ||
|
||
# Check SQS queue exists | ||
aws sqs get-queue-url --queue-name celery | ||
#if aws sqs get-queue-url --queue-name celery > /dev/null 2> /dev/null | ||
#then | ||
# sqs_status="HEALTHY" | ||
#else | ||
# sqs_status="HEALTHY"; #Passing the status as healthy in all scenarios | ||
#fi | ||
if aws sqs get-queue-url --queue-name celery > /dev/null 2> /dev/null | ||
then | ||
sqs_status="HEALTHY" | ||
else | ||
sqs_status="UNHEALTHY"; | ||
exit_code=1; | ||
fi | ||
|
||
# Check Postgres DB is ready | ||
pg_isready -d "$DATABASE_URL" | ||
#if pg_isready -d "$DATABASE_URL" > /dev/null 2> /dev/null | ||
#then | ||
# pg_status="HEALTHY" | ||
#else | ||
# pg_status="UNHEALTHY"; | ||
#fi | ||
if pg_isready -d "$DATABASE_URL" > /dev/null 2> /dev/null | ||
then | ||
pg_status="HEALTHY" | ||
else | ||
pg_status="UNHEALTHY"; | ||
exit_code=1; | ||
fi | ||
|
||
# Provide JSON output | ||
#jq ".version=\"$GIT_COMMIT\" | (.dependencies[] | select(.name==\"request-db\")).status=\"$pg_status\" | (.dependencies[] | select(.name==\"sqs\")).status=\"$sqs_status\"" healthcheck-output-template.json | ||
jq ".version=\"$GIT_COMMIT\" | (.dependencies[] | select(.name==\"request-db\")).status=\"$pg_status\" | (.dependencies[] | select(.name==\"sqs\")).status=\"$sqs_status\"" healthcheck-output-template.json | ||
|
||
exit $exit_code | ||
|
||
# Note use of > /dev/null 2> /dev/null which suppresses stout and stderr | ||
# Note use of > /dev/null 2> /dev/null which suppresses stout and stderr |