Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use virtualenvwrapper in Supervisor?

Tags:

When I was developing and testing my project, I used to use virtualenvwrapper to manage the environment and run it:

workon myproject python myproject.py 

Of course, once I was in the right virtualenv, I was using the right version of Python, and other corresponding libraries for running my project.

Now, I want to use Supervisord to manage the same project as it is ready for deployment. The question is what is the proper way to tell Supervisord to activate the right virtualenv before executing the script? Do I need to write a separate bash script that does this, and call that script in the command field of Supervisord config file?

like image 791
MLister Avatar asked Mar 04 '13 13:03

MLister


People also ask

How does virtualenvwrapper work?

virtualenvwrapper is a set of extensions to Ian Bicking's virtualenv tool. The extensions include wrappers for creating and deleting virtual environments and otherwise managing your development workflow, making it easier to work on more than one project at a time without introducing conflicts in their dependencies.

How do I use virtualenvwrapper in Python 3?

Create a Python3 based virtual environment. Optionally enable --system-site-packages flag. Set into the virtual environment. Install other requirements using pip package manager.

What is the difference between virtualenv and virtualenvwrapper?

Virtualenvwrapper is a utility on top of virtualenv that adds a bunch of utilities that allow the environment folders to be created at a single place, instead of spreading around everywhere.


1 Answers

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 
like image 106
dm03514 Avatar answered Oct 05 '22 15:10

dm03514