Set environment variables with supervisor for Flask

跟風遠走 提交于 2019-12-24 00:54:48

问题


My supervisor configuration file:

[program:dashboard]
command = /home/ubuntu/dashboard/bin/gunicorn manage:app -w 4
directory = /home/ubuntu/dashboard
autostart=true
autorestart=true
user = ubuntu
stdout_logfile = /home/ubuntu/dashboard/logs/gunicorn/gunicorn_stdout.log
stderr_logfile = /home/ubuntu/dashboard/logs/gunicorn/gunicorn_stderr.log
redirect_stderr = True
environment=SECRET_KEY="a_key",FLASK_CONFIG="production",DB_HOST="a_host",DB_PASSWORD="a_password",DB_USERNAME="a_username"

In my Flask app I read the values like:

DB_HOST = os.environ.get('DB_HOST')
DB_USERNAME = os.environ.get('DB_USERNAME')
DB_PASSWORD = os.environ.get('DB_PASSWORD')

But this doesn't work. These fields are defined as NoneType.

来源:https://stackoverflow.com/questions/36572205/set-environment-variables-with-supervisor-for-flask

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!