当前位置: 动力学知识库 > 问答 > 编程问答 >

python - Set environment variables with supervisor for Flask

问题描述:

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.

分享给朋友:
您可能感兴趣的文章:
随机阅读: