Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Supervising virtualenv django app via supervisor

I'm trying to use supervisor in order to manage my django project running gunicorn inside a virtualenv. My conf file looks like this:

[program:diasporamas] command=/var/www/django/bin/gunicorn_django directory=/var/www/django/django_test process_name=%(program_name)s user=www-data autostart=false stdout_logfile=/var/log/gunicorn_diasporamas.log stdout_logfile_maxbytes=1MB stdout_logfile_backups=2 stderr_logfile=/var/log/gunicorn_diasporamas_errors.log stderr_logfile_maxbytes=1MB stderr_logfile_backups=2enter code here 

The problem is, I need supervisor to launch the command after it has run 'source bin/activate' in my virtualenv. I've been hanging around google trying to find an answer but didn't find anything.

Note: I don't want to use virtualenvwrapper

Any help please?

like image 201
Oleiade Avatar asked Jun 30 '11 09:06

Oleiade


1 Answers

The documentation for the virtualenv activate script says that it only modifies the PATH environment variable, in which case you can do:

[program:diasporamas] command=/var/www/django/bin/gunicorn_django directory=/var/www/django/django_test environment=PATH="/var/www/django/bin" ... 

Since version 3.2 you can use variable expansion to preserve the existing PATH too:

[program:diasporamas] command=/var/www/django/bin/gunicorn_django directory=/var/www/django/django_test environment=PATH="/var/www/django/bin:%(ENV_PATH)s" 

...

like image 123
Michał Modzelewski Avatar answered Oct 07 '22 18:10

Michał Modzelewski