in an Ubuntu 16.04 server, I run following commands in the python shell:
>>> import os
>>> os.environ
and the output is:
environ({'DJANGO_DB_USERNAME': 'siteuser', 'DJANGO_DB_PASSWORD':
'123456','DJANGO_SECRET_ KEY': 'xvia%9op!4q$%w@o8t9f%pa%sdfsdfbu+sdfsdf',
'DJANGO_DB_NAME': 'some_name', ..., ..., other keys})
it means environment variables have been set correctly.
but when I run the sudo systemctl status gunicorn
for checking gunicorn status, the os.environ
doesn't work properly.
this is the output, when gunicorn runs the django:
environ({'LANGUAGE': 'en_US:en', 'PATH':
'/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
'DJANGO_SETTINGS_MODULE': 'config.settings.production', 'SERVER_SOFTWARE':
'gunicorn/19.8.1', 'USER': 'mojtaba'})
the following keys DJANGO_DB_NAME, DJANGO_DB_USERNAME, DJANGO_DB_PASSWORD, DJANGO_SECRET_KEY
are not found. also other variables are not shown.
who knows what's the problem??