title: Why are my environment variables not detected when starting up celery?
body: <p>I am running django on centos served by apache and mod_wsgi. I followed the instructions to set up celery to be run as a daemon. </p>
  
  <p>I put this init script <a href="https://github.com/celery/celery/blob/3.1/extra/generic-init.d/celeryd" rel="noreferrer">https://github.com/celery/celery/blob/3.1/extra/generic-init.d/celeryd</a> in <code>/etc/init.d/celeryd</code></p>
  
  <p>and set up the configuration in </p>
  
  <pre><code>/etc/default/celeryd 
  </code></pre>
  
  <p>I am using environment variables in my django settings.py file so I can use different configurations in my development and production environments. I know these environment variables are set correctly because the app has been working this whole time. I think that celery is just not getting the variable passed to it or something. </p>
  
  <p>I checked by typing the <code>env</code> command. variables are showing fine. </p>
  
  <p>To start up I just do: </p>
  
  <pre><code>service celeryd start
  </code></pre>
  
  <p>It tries to start up but throws an error saying that I do not have my environment variables set. </p>
  
  <p>I wrote a function to grab environment variables. that is what throws the error. </p>
  
  <pre><code>def get_env_variable(var_name):
      try:
          return os.environ[var_name]
      except KeyError:
          error_msg = "Set the %s environment variable" % var_name
          raise ImproperlyConfigured(error_msg)
  </code></pre>
  
  <p>The only way that error is thrown is if the environment variable is not set correctly. </p>
  
  <p>Does anyone know why celery is not detecting the enironment variables that I have set?</p>