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.
This commit is contained in:
Yocum 2019-07-22 16:46:18 -04:00 committed by Ryan Kuba
parent 18a43a173e
commit 5a4222c4b0

View File

@ -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]}