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

查看:36
本文介绍了如何在主管中使用 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.

对我来说,我在 .virtualenvs 目录中有我的虚拟环境.例如

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

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

无需工作

对于 supervisor.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天全站免登陆