当我运行sudo -E supervisor重读/重新加载
时我在[program:site]部分定义了命令来启动gunicorn.conf.py
/etc/supervisor/conf.d/weather.conf
Yus level '1'
gunicorn.conf.py
[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
它会显示错误。
我在/etc/profile.d/project.sh
中设置# -*- coding: utf-8 -*-
# /usr/bin/python3
import os
bind = "{}:8080".format(os.environ['DJANGO_WEATHER_STATION_HOST'])
worders = (os.sysconf('SC_NPROCESSORS_ONLN') * 2) + 1
loglevel = 'error'
command = "WTR_VENV/gunicorn"
pythonpath = "$PROJECT/weather_station"
project.sh
DJANGO_WEATHER_STATION_HOST
重装后却徒劳无功。
我也设置了〜/ .profile
但仍然有错误。
文件 “/home/nhcc/campus-weather-station/weather_station/gunicorn.conf.py” 5号线,在 bind =“{}:8080”.format(os.environ ['DJANGO_WEATHER_STATION_HOST'])文件“/usr/lib/python3.5/os.py”,第725行, getitem 从无KeyError引发KeyError(key):'DJANGO_WEATHER_STATION_HOST'
答案 0 :(得分:1)
主管维持自己的环境。
在这里阅读更多。 http://supervisord.org/subprocess.html#subprocess-environment
所以你必须在/etc/supervisor/conf.d/weather.conf
文件中传递环境。
/etc/supervisor/conf.d/weather.conf
之前设置env
。
[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"