#!/usr/bin/with-contenv bash

# need to safely handle exiting the existing worker bots and
# redis queue when container restarts or stops

_term() {
	/bin/bash /app/cleanup.sh
}

trap _term SIGTERM

declare -A REDIS_CONF
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]}