Reputation: 479
when I run sudo -E supervisor reread/reload
I have the command defined in the [program:site] section to launch the gunicorn.conf.py
/etc/supervisor/conf.d/weather.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
# -*- 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"
it will showed up the error .
I set DJANGO_WEATHER_STATION_HOST
in the /etc/profile.d/project.sh
project.sh
export DJANGO_WEATHER_STATION_HOST=the_host_ip
After reloading it but in vain.
I also set in the ~/.profile
But still got the error.
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'
Upvotes: 0
Views: 1636
Reputation: 1861
Supervisor maintains its own environment.
Read here more. http://supervisord.org/subprocess.html#subprocess-environment
So you have to pass environment in /etc/supervisor/conf.d/weather.conf
file.
Ex of /etc/supervisor/conf.d/weather.conf
with env
set.
[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"
Upvotes: 2