I have a docker-compose.yml
file that defines a number of services. One is a redis
instance, and another is a queue-worker
.
The queue-worker
fetches jobs from redis
and performs the necessary work.
Currently, I have the queue-worker
's stop_grace_period
set to 5m
, within my docker-compose.yml
. The idea here is that when I run docker-compose down
, the queue-worker
will have 5 minutes to deal with any remaining jobs in the queue, before shutting down.
I would like to improve the situation, if possible, by performing a check when docker-compose down
is called. If the result of the check is true, e.g. curl http://project/total-jobs-in-queue == 0
then go ahead and stop the queue-worker
container immediately. If the result is false, i.e. there are still jobs in the work queue, delay container shutdown until the result of the check is true.
I could write a bash script to perform this check, and shut the containers individually, from within the script, however if it was possible to configure this in such a way that the standard docker-compose up/down
commands could continue to be used, that would be much more preferable.
Is this possible?