【问题标题】:Environment variables with Supervisor带有主管的环境变量
【发布时间】:2013-06-02 22:49:01
【问题描述】:

我已经按照this blogpost 设置了主管来运行 celeryd、celerycam 和 gunicorn。一开始一切都很顺利。第一次重启后,什么都没有启动。我能看到的日志是这种形式的。

未知命令:'run_gunicorn'

键入“manage.py help”以了解用法。

我猜这是因为主管没有“看到”我的环境变量,如 DJANGO_SETTINGS_MODULE、DB_HOST 等。我将它们全部放在 /etc/environment 中,但它没有用。同样,我尝试将它们放在 /etc/supervisor/supervisord.conf 中 [supervisor] 下的 environment 标签上。我收到以下错误

启动主管:错误:格式字符串 '\'DEBUG\'="False", \'DJANGO_SETTINGS_MODULE\'="project.settings.production",for “环境”格式错误

我的supervisord.conf在[supervisord]下有如下内容

[supervisord]
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
childlogdir=/var/log/supervisor            ; ('AUTO' child log dir, default $TEMP)

; the below section must remain in the config file for RPC
; (supervisorctl/web interface) to work, additional interfaces may be
; added by defining them in separate rpcinterface: sections
environment = 'DEBUG'="False",'DJANGO_SETTINGS_MODULE'="project.settings.production",

[更新 - 添加来自 celery、gunicorn、celerycam 的日志]

来自 celeryd_err.log 的日志

ImportError: 没有名为 debug_toolbar 的模块

ImportError: 没有名为 debug_toolbar 的模块

ImportError: 没有名为 debug_toolbar 的模块

来自 celerycam_err.log 的日志

ImportError: 没有名为 debug_toolbar 的模块

ImportError: 没有名为 debug_toolbar 的模块

ImportError: 没有名为 debug_toolbar 的模块

来自 gunicorn_err.log 的日志

键入“manage.py help”以了解用法。

未知命令:'run_gunicorn'

键入“manage.py help”以了解用法。

未知命令:'run_gunicorn'

键入“manage.py help”以了解用法。

未知命令:'run_gunicorn'

对我在哪里可以获得解决方案有任何建议吗?提前感谢您的帮助!

【问题讨论】:

  • 你的settings模块的目录结构是什么?
  • 当您尝试启动服务器时,您确定您仍在您的环境中吗?
  • @J.Ghyllebert 我实际上并没有在此服务器中使用虚拟环境。此服务器将专门用于此项目。
  • @karthikr 我正在为这个项目使用twoscoops-of-django 模板。
  • 如果你需要查看我的celeryd.conf和其他conf文件,请在此处留言。

标签: django deployment environment-variables supervisord


【解决方案1】:

编辑 gunicorn.conf 文件可能更合适。

它应该看起来像:

[program:gunicorn]
...
environment=DJANGO_SETTINGS_MODULE='project.settings.production',DEBUG='False'

请注意,结尾没有逗号,“键”没有被引用,值被引用。如果您只使用字母数字值,则不需要引号,但这样做更安全。

为确保您的配置文件在supervisor中是好的,请执行以下操作:

sudo supervisorctl
reread

处理可能输出的任何错误。

发现需要重新加载supervisor才能使配置文件生效:

sudo supervisorctl
reload

【讨论】:

    猜你喜欢
    • 2012-10-05
    • 1970-01-01
    • 2015-11-04
    • 2021-11-03
    • 2019-01-17
    • 1970-01-01
    • 2014-05-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多