X
X
xenofobius2018-02-20 11:31:31
Django
xenofobius, 2018-02-20 11:31:31

Why doesn't supervisor start with django-configurations?

I did it according to the tutorial (launching via manage.py and gunicorn works directly), through the supervisor in the logs I see the following:

>>> Configuration cannot be imported, environment variable DJANGO_CONFIGURATION is undefined.configurations.readthedocs.org/

in bashrc
export DJANGO_CONFIGURATION=TestServ
export DJANGO_SETTINGS_MODULE=MySite.settings

Visor settings:
[program:mysite]
command=/home/user/venv/bin/gunicorn MySite.wsgi:application -c /home/user/MySite/MySite/gunicorn.conf.py
directory=/home/user/MySite
user=user
autorestart=true
redirect_stderr=true

If you add
environment=
DJANGO_CONFIGURATION=TestServ
DJANGO_SETTINGS_MODULE=MySite.settings
to mysite.conf, then the launch error is already in the logs:
gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>

If you use the supervisor without django-configurations with native settings, then everything is OK, I can’t understand the reason why the supervisor refuses to see environment variables

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
ksenofobius, 2018-02-20
@ksenofobius

I could not find an answer to the question why the supervisor does not initially see the environment variables, but if someone has a similar problem, then here is a way to pass the virtual environment variables: in the hunicorn config file you need to add:

raw_env = [
    "DJANGO_CONFIGURATION=Dev",
    "DJANGO_SETTINGS_MODULE=myapp.settings",
]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question