本文介绍了通过主管监督 virtualenv django 应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用主管来管理我在 virtualenv 中运行 gunicorn 的 django 项目.我的 conf 文件如下所示:

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

问题是,在我的 virtualenv 中运行source bin/activate"后,我需要主管来启动命令.我一直在谷歌上闲逛,试图找到答案,但什么也没找到.

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.

注意:我不想使用 virtualenvwrapper

Note: I don't want to use virtualenvwrapper

请问有什么帮助吗?

推荐答案

documentation 说它只修改 PATH 环境变量,在这种情况下你可以这样做:

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"
...

从 3.2 版开始,您也可以使用 变量扩展 来保留现有的 PATH:

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"

...

这篇关于通过主管监督 virtualenv django 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-17 16:58