Python 使用管理器为烧瓶设置环境变量

Python 使用管理器为烧瓶设置环境变量,python,flask,supervisord,Python,Flask,Supervisord,我的主管配置文件: [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 std

我的主管配置文件:

[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"
在我的Flask应用程序中,我读取如下值:

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

但这不起作用。这些字段定义为
NoneType

相关:我见过这一个,但在我的例子中,环境变量以前不存在,它们用逗号分隔。相关:我将配置文件更改为:
command=/home/ubuntu/dashboard/bin/gunicorn-e DB_HOST=“a_HOST”-e DB_USERNAME=“a_USERNAME”-e DB_PASSWORD=“a_password”manage:app-w4
也不起作用。你仍然有这个问题吗?我成功地将我的
环境
列表移动到
用户
下和
标准日志文件
上。我认为这些东西是位置独立的,但可能不是100%正确的?只是猜测,但它可能有助于解决你的问题。