如何在主管中使用virtualenvwrapper? [英] How to use virtualenvwrapper in Supervisor?

查看:174
本文介绍了如何在主管中使用virtualenvwrapper?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我开发和测试我的项目时,我曾经使用virtualenvwrapper来管理环境并运行它:

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

当然,一旦我在右边的virtualenv,我正在使用正确的Python版本和其他相应的库来运行我的项目。

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.

现在,我想使用Supervisord来管理同样的项目, 。问题是在执行脚本之前告诉Supervisord激活正确的virtualenv的正确方法是什么?我需要写一个单独的bash脚本来执行此操作,并在Supervisord配置文件的命令字段中调用该脚本?

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?

推荐答案

从命令行使用virtualenv的一种方法是使用位于virtualenv内部的python可执行文件。

One way to use your virtualenv from the command line is to use the python executable located inside of your virtualenv.

对于我,我有我的虚拟envs在$ code> .virtualenvs 目录。例如

for me i have my virtual envs in .virtualenvs directory. For example

/home/ubuntu/.virtualenvs/yourenv/bin/python

不需要管理员 workon

conf 管理龙卷风应用程序:

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

这篇关于如何在主管中使用virtualenvwrapper?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆