Supervisord and django-celery: Stop the process properly

Just noted when I stopped the django-celery app which monitored by supervisord with:

# supervisorctl stop myappcelery

The status show myappcelery had stopped:

# supervisorctl status

myappcelery                         STOPPED    Nov 20 10:48 AM


But, the python processed of django-celery were still running:

# ps aux | grep celery

root     25729  9.0  1.8 225676 38188 ?        S    11:07   0:00 python /mydjangoapp/manage.py celeryd --pool=eventlet -v 2 -B -s celery -E -l info
root     25748  1.0  1.7 164640 36596 ?        S    11:07   0:00 python
/mydjangoapp/manage.py celeryd --pool=eventlet -v 2 -B -s celery -E


Then, I take a look at the supervisord configuration for my django app:

[program:ptccele]
directory=/mydjangoapp/
command=/mydjangoapp/shellscripts/production/ptccele.sh
user=root
autostart=true
autorestart=true
stdout_logfile=/var/log/cele.log
stderr_logfile=
/var/log/cele_error.log
redirect_stderr=true


I used a shellscript to run the celery worker. Supervisord was managing sh scripts, not python threads. So, I change the command to run the python process directly:

[program:ptccele]
directory=/mydjangoapp/
command=python /mydjangoapp/manage.py celeryd --pool=eventlet -v 2 -B -s celery -E
user=root
autostart=true
autorestart=true
stdout_logfile=/var/log/cele.log
stderr_logfile=/var/log/cele_error.log
redirect_stderr=true



Update the supervisord app:

# supervisord update


Now, the python processes will be killed when I stop the supervisor app.

Comments