K
K
Kwad2020-03-19 20:28:41
JavaScript
Kwad, 2020-03-19 20:28:41

Why doesn't it see SECRET_KEY when run through gunicorn?

When running through runserver - everything is fine.
I run through: gunicorn djecommerce.wsgi:application - gives this:

(cloudenv) [email protected]:~/cloudproject# gunicorn djecommerce.wsgi:application
[2020-03-19 17:19:02 +0000] [24419] [INFO] Starting gunicorn 20.0.4
[2020-03-19 17:19:02 +0000] [24419] [INFO] Listening at: http://127.0.0.1:8000 (24419)
[2020-03-19 17:19:02 +0000] [24419] [INFO] Using worker: sync
[2020-03-19 17:19:02 +0000] [24422] [INFO] Booting worker with pid: 24422
[2020-03-19 17:19:02 +0000] [24422] [ERROR] Exception in worker process
Traceback (most recent call last):
  File "/root/cloudproject/cloudenv/lib/python3.6/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
    worker.init_process()
  File "/root/cloudproject/cloudenv/lib/python3.6/site-packages/gunicorn/workers/base.py", line 119, in init_process
    self.load_wsgi()
  File "/root/cloudproject/cloudenv/lib/python3.6/site-packages/gunicorn/workers/base.py", line 144, in load_wsgi
    self.wsgi = self.app.wsgi()
  File "/root/cloudproject/cloudenv/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
    self.callable = self.load()
  File "/root/cloudproject/cloudenv/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 49, in load
    return self.load_wsgiapp()
  File "/root/cloudproject/cloudenv/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp
    return util.import_app(self.app_uri)
  File "/root/cloudproject/cloudenv/lib/python3.6/site-packages/gunicorn/util.py", line 358, in import_app
    mod = importlib.import_module(module)
  File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/root/cloudproject/djecommerce/wsgi.py", line 7, in <module>
    application = get_wsgi_application()
  File "/root/cloudproject/cloudenv/lib/python3.6/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
    django.setup(set_prefix=False)
  File "/root/cloudproject/cloudenv/lib/python3.6/site-packages/django/__init__.py", line 19, in setup
    configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
  File "/root/cloudproject/cloudenv/lib/python3.6/site-packages/django/conf/__init__.py", line 79, in __getattr__
    self._setup(name)
  File "/root/cloudproject/cloudenv/lib/python3.6/site-packages/django/conf/__init__.py", line 66, in _setup
    self._wrapped = Settings(settings_module)
  File "/root/cloudproject/cloudenv/lib/python3.6/site-packages/django/conf/__init__.py", line 176, in __init__
    raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.")
django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.
[2020-03-19 17:19:02 +0000] [24422] [INFO] Worker exiting (pid: 24422)
[2020-03-19 17:19:02 +0000] [24419] [INFO] Shutting down: Master
[2020-03-19 17:19:02 +0000] [24419] [INFO] Reason: Worker failed to boot.


SECRET KEY is located in the root of the project, in the .env file

Answer the question

In order to leave comments, you need to log in

3 answer(s)
Y
y0u, 2019-08-20
@y0u

the console says an error in another file, but it is not there because everything works in a different template
No, it is there, since it shows such an error.
This error says that instead of a string, you passed undefined to the split method.
Look further on your own for the place where you must pass a string, and pass undefined.

D
Dimonchik, 2020-03-19
@dimonchik2013

check the path and the rights of the
right especially - like the root you manually, the gunicorn from the web server is usually

K
Kwad, 2020-03-19
@Kwad

Like this with pens5e73b43320d1d476439077.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question