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