Signal propagation into DockerOperator container #55129
-
I am running a docker compose file which looks like:
Along with a dag which runs the following:
Where ws.py is:
I need shutdown_task() to always run when the program ends or received a shutdown signal. According the comment in the docker compose (which I've taken from the official one) I tried setting DUMB_INIT_SETSID="1" as an environment variable within DockerOperator, which didn't work. When I change it to "1" in my docker compose it does seem to work, but I think this is not recommended (described here). I've tried several other things to no avail. I found a similar unanswered stack overflow question here. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You can read more how celery processes signals here https://docs.celeryq.dev/en/stable/userguide/workers.html#process-signals and decide yourself what you want to do. If you want to terminate your tasks on TERM, surely you can set DUMB_INIT_SESSID to 1: - this will propagate the TERM signal to all running celery tasks. Also you can use QUIT instead of term to make celery do it on it's own. the DUM_INIT_SESSID: 0 is simply to preserve default Celery behaviour when if it receives TERM, it does warm shutdown when it stops picking new tasks but it will let all running tasks to complete. You can also send SIGTERM twice BTW. When Celery is in "warm shutdown" mode second TERM signal will initiate cold shutdown |
Beta Was this translation helpful? Give feedback.
You can read more how celery processes signals here https://docs.celeryq.dev/en/stable/userguide/workers.html#process-signals and decide yourself what you want to do.
If you want to terminate your tasks on TERM, surely you can set DUMB_INIT_SESSID to 1: - this will propagate the TERM signal to all running celery tasks. Also you can use QUIT instead of term to make celery do it on it's own. the DUM_INIT_SESSID: 0 is simply to preserve default Celery behaviour when if it receives TERM, it does warm shutdown when it stops picking new tasks but it will let all running tasks to complete.
You can also send SIGTERM twice BTW. When Celery is in "warm shutdown" mode second TERM signal will initiat…