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

问题描述

我正在尝试使用主管来管理我的django项目,在virtualenv内运行枪支。
我的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

问题是,我需要主管在运行命令之后启动命令源bin / activate'在我的virtualenv。我一直在google上试图找到答案,但没有找到任何东西。

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

有任何帮助吗?

推荐答案

为virtualenv激活脚本说,它只修改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应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-29 05:16