Sunday 15 September 2013

django - How to set environment variables for nginx to read? -


I'm trying to set my own design "SECRET_KEY" in an environment variable.

Export to Virtual Virtual Virtualweepers

  workon mydomain.com   

I typed

  SECRET_KEY = xxxxxx   

When I try to

  $ SECRET_KEY echo   

I get my value (Xxxxxx)

So far so good but when I try to use my site in a browser (using ngnix and gunicorn) I get an error.

Here is my supervisor script for gonochorn

  [program: gunicorn] directory = /home/<USER>/.virtualenvs/<DOMAIN>/< PROJECT & gt; / order = / home / & lt; Users & gt; / Virtualenvs /. & Lt; Domain & gt; / Bin / gunicorn & lt; Project & gt; Wsgi: Application-c /home/<USER>/.virtualenvs/<DOMAIN>/<PROJECT>/<APP>/gunicorn_conf.py User = & lt; USER & gt;   

Here's my gunicorn_conf.py: bind = "127.0.0.1:8000" logfile = "/ home /

This is my setting:

  def get_env_variable (var_name): try: return os.environ [var_name] except keyError: Error_msg = "% S environment variable "% var_name improperly processed (error_MS g) SECRET_KEY = get_env_variable (" SECRET_KEY ")   

How can I set my environment variable correctly so that ngnix it Can read?

Edit: Traceback:
  Traceback (most recent call final): File "/home/<USTER>/.virtualenvs/<DOMAIN>/ Local / lib /python2.7/site-packages/gunicorn/workers/sync.py ", line 125, handle_request respiter = self.wsgi (environment, resp.start_response) in the file" /home/<USER>/.virtualenvs /> File & quot; domain & gt; /downloads/django-trunk/django/core/handlers/wsgi.py ", line 236, __call__ self.load_middleware () file" /home/<USER>/.virtualenvs/< DOMAIN & gt; / downloads / Django- trunk / Django /core/handlers/base.py ", line 46, in load_middleware to middleware_path in settings.MIDDLEWARE_CLASSES: file" /home/<USER>/.virtualenvs/<DOMAIN> / Downloads / django-trunk / django / conf / __init__.py ", line 53, __geta File ttr__ self._setup (name) "/home/<USER>/.virtualenvs/<DOMAIN>/downloads/django-trunk/django/conf/__init__.py", line 48, _setup self._wrapped = Settings in (settings_module) file "/home/<USER>/.virtualenvs/<DOMAIN>/downloads/django-trunk/django/conf/__init__.py", line 126, in __init__ Mod = importlib.import_module (self. SETTINGS_MODULE) file "/home/<USER>/.virtualenvs/<DOMAIN>/downloads/django-trunk/django/utils/importlib.py", line 35, import_module __import __ (name) file "/ home / & Lt; USER & gt; / virtualenvs / & lt; DOMAIN & gt; / & lt; PROJECT & gt; /    

inside the variable variable

You can define the instructions with the supervisor config = var1 = & lt; Var1 & gt ;, var2 = & lt; Var2 & gt;

Something similar:

  [program: gunicorn] directory = / home / & lt; Users & gt; / Virtualenvs /. & Lt; Domain & gt; / & LT; Project & gt; / Command = / home / & lt; Users & gt; / Virtualenvs / & lt; Domain & gt; / Bin / gunicorn & lt; Project & gt; .wsgi: /home/<USER>/.virtualenvs/<DOMAIN>/<PROJECT>/<APP>/gunicorn_conf.py user = & lt -c application, user & gt; Environment = SECRET_KEY = & lt; SECRET_KEY & gt;    

No comments:

Post a Comment