From 5a4222c4b030d6fc84f49a3f4ac86521c791091a Mon Sep 17 00:00:00 2001 From: Yocum Date: Mon, 22 Jul 2019 16:46:18 -0400 Subject: [PATCH] Fix redis cleanup Cleanup.sh was unable to read array vars and would error out. Moved commands directly into the sigterm trap so the cleanup actually runs. --- root/etc/services.d/rq-dashboard/run | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/root/etc/services.d/rq-dashboard/run b/root/etc/services.d/rq-dashboard/run index de91643..55ae6fd 100644 --- a/root/etc/services.d/rq-dashboard/run +++ b/root/etc/services.d/rq-dashboard/run @@ -3,7 +3,22 @@ # need to safely handle exiting the existing worker bots and # redis queue when container restarts or stops _term() { - /bin/bash /app/cleanup.sh + #/bin/bash /app/cleanup.sh + # Redis Cleanup + # killing existing workers before starting new ones + echo "killing existing workers..." + if [ -f "/tmp/diskover_bot_pids" ]; then + /bin/bash /app/diskover/diskover-bot-launcher.sh -k > /dev/null 2>&1 + sleep 3 + fi + # empty existing redis queue + echo "emptying current redis queues..." + rq empty -u redis://"${DISKOVER_ARRAY[REDIS_HOST]}":"${DISKOVER_ARRAY[REDIS_PORT]}" diskover_crawl diskover diskover_calcdir failed + sleep 3 + # kill dangling workers + echo "killing dangling workers..." + /bin/bash /app/diskover/diskover-bot-launcher.sh -k > /dev/null 2>&1 + sleep 3 } trap _term SIGTERM @@ -13,4 +28,4 @@ REDIS_CONF[REDIS_HOST]=${REDIS_HOST:-redis} REDIS_CONF[REDIS_PORT]=${REDIS_PORT:-6379} exec \ - s6-setuidgid abc /usr/bin/rq-dashboard -H ${REDIS_CONF[REDIS_HOST]} -P ${REDIS_CONF[REDIS_PORT]} + s6-setuidgid abc /usr/bin/rq-dashboard -H ${REDIS_CONF[REDIS_HOST]} -P ${REDIS_CONF[REDIS_PORT]} \ No newline at end of file