Мой скрипт на python сейчас использует os.environ ['SECRET_KET'].Сервер запускается с системной службой:
[Unit]
Description=Escota Dev Service
After=multi-user.target
[Service]
Type=simple
User=vagrant
WorkingDirectory=/var/www/myproject
ExecStart=/var/www/myproject/env/bin/python web/myproject_project/manage.py runserver 127.0.0.1:8000
Restart=on-abort
[Install]
WantedBy=multi-user.target
Служба запущена:
● myproject-dev.service - myproject Dev Service
Loaded: loaded (/lib/systemd/system/myproject-dev.service; enabled; vendor preset: enabled)
Active: active (running) since mer. 2018-09-19 10:18:35 CEST; 179ms ago
Main PID: 10081 (python)
Tasks: 1
Memory: 1.2M
CPU: 58ms
CGroup: /system.slice/myproject-dev.service
└─10081 /var/www/myproject/env/bin/python web/myproject_project/manage.py runserver 127.0.0.1:8000
sept. 19 10:18:35 vm systemd[1]: Started myproject Dev Service.
И, наконец, сообщение об ошибке:
[CRITICAL] -> 19/09/2018 09:10 : ('Environment(Config) Error ! => ', ConnectionError(MaxRetryError("HTTPConnectionPool(host='localhost', port=8000): Max retries exceeded with url: /firerisk/zone/ (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fe9b4d72b38>: Failed to establish a new connection: [Errno 111] Connection refused',))",),), <class 'requests.exceptions.ConnectionError'>)
Но этоне имеет значения, потому что настоящая ошибка:
Sep 19 10:18:39 vm python[10081]: File "/var/www/myproject/web/myproject_project/myproject_project/settings.py", line 30, in <module>
Sep 19 10:18:39 vm python[10081]: if os.environ['SECRET_KEY']:
Sep 19 10:18:39 vm python[10081]: File "/var/www/escota/env/lib/python3.5/os.py", line 725, in __getitem__
Sep 19 10:18:39 vm python[10081]: raise KeyError(key) from None
Sep 19 10:18:39 vm python[10081]: KeyError: 'SECRET_KEY'
Можете ли вы помочь мне?Спасибо.
Фабрис