将 DJANGO_SETTINGS_MODULE 导出为主管中的环境变量
Export DJANGO_SETTINGS_MODULE as environment variable in supervisor
我的项目基于虚拟环境中的 Django、Nginx、Gunicorn 和 Supervisor。
我在 ./bin/activate
脚本末尾导出环境变量。每当我 source
激活文件时,它都会导出环境变量。很酷...
我在启动 Supervisor 脚本时遇到了问题。似乎 ./bin/activate
不是来源,因为 Django 无法获得诸如 SECRET_KEY.
之类的变量
我听说有人在使用我的 virtualenv bin 目录中没有的 post-activate 脚本。我错过了什么重要的东西吗?为什么 Supervisor 不获取 ./bin/activate
脚本?
这是我的主管会议:
command=/opt/.virtualenvs/plcweb/bin/gunicorn plcweb.config.wsgi -c /opt/plcweb/gunicorn.conf.py
directory=/opt/plcweb/project
user=bastien
autostart=true
autorestart=true
redirect_stderr=True
stdout_logfile=/opt/plcweb/gunicorn.log
stderr_logfile=/opt/plcweb/gunicorn.log
如 here 所述,使用 environment
指令可以得到一个非常简单的解决方案。所以要导出 DJANGO_SETTINGS_MODULE,supervisor conf 文件应该如下所示:
command=/opt/.virtualenvs/plcweb/bin/gunicorn plcweb.config.wsgi -c /opt/plcweb/gunicorn.conf.py
environment=DJANGO_SETTINGS_MODULE=my_project.settings.production
directory=/opt/plcweb/project
user=bastien
我的项目基于虚拟环境中的 Django、Nginx、Gunicorn 和 Supervisor。
我在 ./bin/activate
脚本末尾导出环境变量。每当我 source
激活文件时,它都会导出环境变量。很酷...
我在启动 Supervisor 脚本时遇到了问题。似乎 ./bin/activate
不是来源,因为 Django 无法获得诸如 SECRET_KEY.
我听说有人在使用我的 virtualenv bin 目录中没有的 post-activate 脚本。我错过了什么重要的东西吗?为什么 Supervisor 不获取 ./bin/activate
脚本?
这是我的主管会议:
command=/opt/.virtualenvs/plcweb/bin/gunicorn plcweb.config.wsgi -c /opt/plcweb/gunicorn.conf.py
directory=/opt/plcweb/project
user=bastien
autostart=true
autorestart=true
redirect_stderr=True
stdout_logfile=/opt/plcweb/gunicorn.log
stderr_logfile=/opt/plcweb/gunicorn.log
如 here 所述,使用 environment
指令可以得到一个非常简单的解决方案。所以要导出 DJANGO_SETTINGS_MODULE,supervisor conf 文件应该如下所示:
command=/opt/.virtualenvs/plcweb/bin/gunicorn plcweb.config.wsgi -c /opt/plcweb/gunicorn.conf.py
environment=DJANGO_SETTINGS_MODULE=my_project.settings.production
directory=/opt/plcweb/project
user=bastien