2017-09-23 2 views
0

wenn ich sudo laufen -E Supervisor wieder gelesen/nachladenPython kann nicht die Umgebungsvariable mit Betreuer lesen

Ich habe den definierten Befehl im [Programm: Website] -Abschnitt der gunicorn.conf.py zu starten

/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" 

wird der Fehler angezeigt.

Ich habe DJANGO_WEATHER_STATION_HOST im /etc/profile.d/project.sh

project.sh

export DJANGO_WEATHER_STATION_HOST=the_host_ip 

Nach dem Nachladen aber vergeblich.

Ich habe auch in der ~/.profile

aber immer noch die Fehlermeldung anzeigt.

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'

+0

Supervisord benötigt env-Variablen, die in der Konfiguration angegeben werden. Siehe: http://supervisord.org/configuration.html#environment-variables –

+0

Mögliche Duplikate von https://stackoverflow.com/questions/12900402/supervisor-and-environment-variables –

+0

Mabe habe ich nicht klar beschrieben. Aber mein Problem ist über die Python-Umgebungsvariable part.Nach dem Ausführen des Supervisor-Befehls die Python-Datei namens.Und der Fehler angezeigt. –

Antwort

1

Supervisor behält seine eigene Umgebung bei.

Lesen Sie hier mehr. http://supervisord.org/subprocess.html#subprocess-environment

So müssen Sie die Umgebung in /etc/supervisor/conf.d/weather.conf Datei übergeben.

Ex von /etc/supervisor/conf.d/weather.conf mit env festgelegt.

[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" 
+0

Mabe Ich habe nicht klar beschrieben.Aber mein Problem ist über die Python-Umgebungsvariable part.Nach dem Ausführen des Supervisor-Befehls die Python-Datei namens.Und der Fehler tauchte auf. –

Verwandte Themen