Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Activating vitualenv within Supervisord

For a little bit of background. I am using Supervisor to monitor a django-celery process. I need to be able to set the virutalenv then start the celeryd process.

The way that I am currently doing it is by, in the supervisor.conf file I have

[program:celery]  
command = /srv/worker.sh

stdout_logfile = /srv/supervisor.log
stderr_logfile = /srv/supervisor.log

Then in worker.sh I have

/bin/su - username -c "source /srv/virtualenvs/bin/activate; python /srv/manage.py celeryd

This works, sort of. The problem is that when I supervisorctl stop celery with supervisor it does not kill the workers. They still remain. I'm thinking if I am able to activate the virtualenv within supervisor, everything will work better than dropping into a shell script.

like image 422
Alexis Avatar asked Dec 03 '25 16:12

Alexis


1 Answers

The TERM signal is getting sent to the shell script instead of celeryd. Either don't use it (because you can set the user from the supervisord conf) or use exec.

Anyway, best practice is (if you don't care about losing some tasks): short stopwaitsecs and killasgroup=true.

Eg:

[program:celery]
command=celeeryd blablabla
user=username 
stopwaitsecs=10
killasgroup=true
like image 140
ionelmc Avatar answered Dec 07 '25 16:12

ionelmc