Skip to content

Commit 5b9fd40

Browse files
shubhwiparikfr
andauthored
Add liveness check for workers (#5886)
* Add liveness check script for workers closes #5885 * delete extra script * Rename worker_healthcheck -> workers_healthcheck --------- Co-authored-by: Arik Fraimovich <[email protected]>
1 parent 0b86c76 commit 5b9fd40

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

bin/docker-entrypoint

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,19 @@ worker() {
2222
exec supervisord -c worker.conf
2323
}
2424

25+
workers_healthcheck() {
26+
WORKERS_COUNT=${WORKERS_COUNT}
27+
echo "Checking active workers count against $WORKERS_COUNT..."
28+
ACTIVE_WORKERS_COUNT=`echo $(rq info --url $REDASH_REDIS_URL -R | grep workers | grep -oP ^[0-9]+)`
29+
if [ "$ACTIVE_WORKERS_COUNT" < "$WORKERS_COUNT" ]; then
30+
echo "$ACTIVE_WORKERS_COUNT workers are active, Exiting"
31+
exit 1
32+
else
33+
echo "$ACTIVE_WORKERS_COUNT workers are active"
34+
exit 0
35+
fi
36+
}
37+
2538
dev_worker() {
2639
echo "Starting dev RQ worker..."
2740

@@ -76,6 +89,10 @@ case "$1" in
7689
shift
7790
worker
7891
;;
92+
workers_healthcheck)
93+
shift
94+
workers_healthcheck
95+
;;
7996
server)
8097
shift
8198
server

0 commit comments

Comments
 (0)