Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

86
Vistas
docker-compose and graceful Celery shutdown

I've been wondering about and searching for solutions for this and I didn't find any.

I'm running Celery in a container built with docker-compose. My container is configured like this:

celery:
  build: .
  container_name: cl01
  env_file: ./config/variables.env
  entrypoint:
    - /celery-entrypoint.sh
  volumes:
    - ./django:/django
  depends_on:
    - web
    - db
    - redis
  stop_grace_period: 1m

And my entrypoint script looks like this:

#!/bin/sh
# Wait for django
sleep 10
su -m dockeruser -c "celery -A myapp worker -l INFO"

Now, if I run docker-compose stop, I would like to have a warm (graceful) shutdown, giving Celery the provided 1 minute (stop_grace_period) to finish already started tasks. However docker-compose stop seems to kill Celery straight away. Celery should also log that it is asked to shut down gracefully, but I don't see anything but an abrupt stop to my task logs.

What am I doing wrong or what do I need to change to make Celery shut down gracefully?

edit: Suggested answer below about providing the --timeout parameter to docker-compose stop does not solve my issue.

about 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

You need to mark celery process with exec, this way celery process will have the same ID as docker command and docker will be able to send a SIGTERM signal to it and gracefully close celery process.

# should be the last command in script
exec celery -A myapp worker -l INFO
about 4 years ago · Santiago Trujillo Denunciar

0

Via docs

Usage: stop [options] [SERVICE...]

Options:
-t, --timeout TIMEOUT      Specify a shutdown timeout in seconds (default: 10).

Try with timeout set to 60 seconds at least.

about 4 years ago · Santiago Trujillo Denunciar

0

Try using this:

docker-compose down 
about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda