A
A
Alexander2018-12-06 16:37:50
Django
Alexander, 2018-12-06 16:37:50

Why does supervisor not see system variables?

my_app.ini:

[program:my_app]
command=/bin/bash /my_app/run.sh
directory=/my_app/
user=gitlab-runner
autostart=true
autorestart=true
stdout_logfile=/my_app/log/service-out.log
stderr_logfile=/my_app/log/service-out.log
stopsignal=INT
stopasgroup=true

run.sh:
#!/usr/bin/env bash

export PROJECT_ROOT=/my_app/
source ${PROJECT_ROOT}/.env/bin/activate

cd ${PROJECT_ROOT}

uwsgi --ini ${PROJECT_ROOT}/uwsgi.ini

After starting, the following error appears in the logs:
File "./config/settings_pro.py", line 7, in <module>
    SECRET_KEY = os.environ['SECRET_KEY']
  File "/usr/lib64/python3.6/os.py", line 669, in __getitem__
    raise KeyError(key) from None
KeyError: 'SECRET_KEY'
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 5330)
spawned uWSGI worker 1 (pid: 5332, cores: 1)
spawned uWSGI worker 2 (pid: 5333, cores: 1)
spawned uWSGI worker 3 (pid: 5334, cores: 1)
spawned uWSGI worker 4 (pid: 5335, cores: 1)
spawned uWSGI worker 5 (pid: 5336, cores: 1)
spawned uWSGI worker 6 (pid: 5337, cores: 1)
spawned uWSGI worker 7 (pid: 5338, cores: 1)
spawned uWSGI worker 8 (pid: 5339, cores: 1)
spawned uWSGI worker 9 (pid: 5340, cores: 1)
spawned uWSGI worker 10 (pid: 5341, cores: 1)

But there is to run it manually:
bash run.sh
There are no problems, all variables are visible.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Ruslan Fedoseev, 2018-12-06
@martin74ua

and SECRET_KEY whose variable? In the plan - which user has it set?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question