Python无法使用supervi读取环境变量

2024-09-30 01:34:12 发布

您现在位置:Python中文网/ 问答频道 /正文

当我运行sudo-E supervisor时重新读取/重新加载

我已经在[项目:现场]启动gunicorn.conf.py在

/etc/主管/conf.d/天气.conf在

[program:site]
directory=/home/nhcc/campus-weather-station/weather_station
command=/home/nhcc/venv/weather_station/bin/gunicorn -c /home/nhcc/campus-weather-station/weather_station/gunicorn.conf.py -p gunicorn.pod weather_station.wsgi

在gunicorn.conf.py在

^{pr2}$

它会显示错误。在

我在/etc/profile.d中设置DJANGO_WEATHER_STATION_HOST/项目.sh在

在项目.sh在

export DJANGO_WEATHER_STATION_HOST=the_host_ip

在重新装载之后,但是没有用。在

我还设置了~/.profile

但还是有错误。在

File "/home/nhcc/campus-weather-station/weather_station/gunicorn.conf.py", line 5, in bind = "{}:8080".format(os.environ['DJANGO_WEATHER_STATION_HOST']) File "/usr/lib/python3.5/os.py", line 725, in getitem raise KeyError(key) from None KeyError: 'DJANGO_WEATHER_STATION_HOST'


Tags: 项目djangopyhosthomeconf错误etc
1条回答
网友
1楼 · 发布于 2024-09-30 01:34:12

主管维护自己的环境。在

更多阅读。http://supervisord.org/subprocess.html#subprocess-environment

所以您必须在/etc/supervisor/conf.d/weather.conf文件中传递环境。在

具有env集的/etc/supervisor/conf.d/weather.conf的Ex。在

[program:site]
directory=/home/nhcc/campus-weather-station/weather_station
command=/home/nhcc/venv/weather_station/bin/gunicorn -c /home/nhcc/campus-weather-station/weather_station/gunicorn.conf.py -p gunicorn.pod weather_station.wsgi

environment=HOME="/home/chrism",USER="chrism"

相关问题 更多 >

    热门问题