How to use virtualenvwrapper in Supervisor?
One way to use your virtualenv from the command line is to use the python executable located inside of your virtualenv.
for me i have my virtual envs in .virtualenvs
directory. For example
/home/ubuntu/.virtualenvs/yourenv/bin/python
no need to workon
for a supervisor.conf
managing a tornado app i do:
command=/home/ubuntu/.virtualenvs/myapp/bin/python /usr/share/nginx/www/myapp/application.py --port=%(process_num)s
Add your virtualenv/bin path to your supervisord.conf
's environment
:
[program:myproj-uwsgi]process_name=myproj-uwsgicommand=/home/myuser/.virtualenvs/myproj/bin/uwsgi --chdir /home/myuser/projects/myproj -w myproj:appenvironment=PATH="/home/myuser/.virtualenvs/myproj/bin:%(ENV_PATH)s"user=myusergroup=myuserkillasgroup=truestartsecs=5stopwaitsecs=10
First, run
$ workon myproject$ dirname `which python`/home/username/.virtualenvs/myproject/bin
Add the following
environment=PATH="/home/username/.virtualenvs/myproject/bin"
to the related supervisord.conf under [program:blabla] section.