[Django]-How to Restart Celery Wroker ran by Supervisord

3πŸ‘

βœ…

The main issue I run into is that long running tasks may get killed if you tell supervisor to killasgroup which would result in lost data.

The solution I’ve moved to using is to tell the mainprocess to TERM which will kill off the workers as they finish their tasks. supervisor will then restart the main process after all the workers finish.

ps aux | grep celery.*MainProcess | awk '{print $2}' | xargs kill -TERM

This is also related.
Celery Production Graceful Restart

πŸ‘€lpiner

1πŸ‘

Add following in supervisor file and restart supervisor.

killasgroup=true

Leave a comment