title: Supervisor Directory not propagated to Celery program
body: <p>I have a Django application (named pcycler) that I need running with Celery. I am attempting to deploy this in production with Supervisor. </p>
  
  <p>I get an error when I run:</p>
  
  <blockquote>
    <p>supervisorctl start celery</p>
  </blockquote>
  
  <p>Which gives me:</p>
  
  <blockquote>
    <p>celery: ERROR (abnormal termination)</p>
  </blockquote>
  
  <p>Here is my celery.conf file, which is included in the supervisor.conf on start.</p>
  
  <pre><code>[program:celery]
  command=/webapps/pcyclerenv/bin/celery -A pcycler worker -l info 
  
  directory=/webapps/pcyclerenv/pcycler
  user=pcycleruser
  numprocs=1
  stdout_logfile=/webapps/pcyclerenv/logs/celeryd_stdout.log
  stderr_logfile=/webapps/pcyclerenv/logs/celeryd_stderr.log
  redirect_stderr=false
  autostart=true
  autorestart=true
  startsecs=10
  stopwaitsecs=600
  killasgroup=true
  priority=998
  </code></pre>
  
  <p>The contents of celeryd_stderr.log is:</p>
  
  <pre><code>Traceback (most recent call last):
    File "/webapps/pcyclerenv/bin/celery", line 11, in &lt;module&gt;
      sys.exit(main())
    File "/webapps/pcyclerenv/local/lib/python2.7/site-packages/celery/__main__.py", line 30, in main
      main()
    File "/webapps/pcyclerenv/local/lib/python2.7/site-packages/celery/bin/celery.py", line 81, in main
      cmd.execute_from_commandline(argv)
    File "/webapps/pcyclerenv/local/lib/python2.7/site-packages/celery/bin/celery.py", line 769, in execute_from_commandline
      super(CeleryCommand, self).execute_from_commandline(argv)))
    File "/webapps/pcyclerenv/local/lib/python2.7/site-packages/celery/bin/base.py", line 304, in execute_from_commandline
      argv = self.setup_app_from_commandline(argv)
    File "/webapps/pcyclerenv/local/lib/python2.7/site-packages/celery/bin/base.py", line 464, in setup_app_from_commandline
      self.app = self.find_app(app)
    File "/webapps/pcyclerenv/local/lib/python2.7/site-packages/celery/bin/base.py", line 484, in find_app
      return find_app(app, symbol_by_name=self.symbol_by_name)
    File "/webapps/pcyclerenv/local/lib/python2.7/site-packages/celery/app/utils.py", line 222, in find_app
      sym = symbol_by_name(app, imp=imp)
    File "/webapps/pcyclerenv/local/lib/python2.7/site-packages/celery/bin/base.py", line 487, in symbol_by_name
      return symbol_by_name(name, imp=imp)
    File "/webapps/pcyclerenv/local/lib/python2.7/site-packages/kombu/utils/__init__.py", line 92, in symbol_by_name
      module = imp(module_name, package=package, **kwargs)
    File "/webapps/pcyclerenv/local/lib/python2.7/site-packages/celery/utils/imports.py", line 101, in import_from_cwd
      return imp(module, package=package)
    File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
      __import__(name)
  ImportError: No module named pcycler
  </code></pre>
  
  <p>Naturally, I decided to go run this program for myself, to see if I can duplicate this error:</p>
  
  <pre><code>pcycleruser@raspberrypi:/webapps/pcyclerenv/pcycler$ pwd
  /webapps/pcyclerenv/pcycler
  
  pcycleruser@raspberrypi:/webapps/pcyclerenv/pcycler$ /webapps/pcyclerenv/bin/celery -A pcycler worker -l info
  
  (... text and pickle deprecation warnings ...)
  
  [2014-05-23 14:52:36,053: WARNING/MainProcess] /webapps/pcyclerenv/local/lib/python2.7/site-packages/celery/fixups/django.py:233: UserWarning: Using settings.DEBUG leads to a memory leak, never use this setting in production environments!
    warnings.warn('Using settings.DEBUG leads to a memory leak, never '
  
  [2014-05-23 14:52:36,066: WARNING/MainProcess] celery@raspberrypi ready.
  </code></pre>
  
  <p>So that works. However, when I am in the wrong directory, such as the following:</p>
  
  <pre><code>pcycleruser@raspberrypi:/webapps/pcyclerenv/pcycler$ cd ..
  
  pcycleruser@raspberrypi:/webapps/pcyclerenv$ pwd
  /webapps/pcyclerenv
  
  pcycleruser@raspberrypi:/webapps/pcyclerenv$ /webapps/pcyclerenv/bin/celery -A pcycler worker -l info
  
  Traceback (most recent call last):
    File "/webapps/pcyclerenv/bin/celery", line 11, in &lt;module&gt;
      sys.exit(main())
    File "/webapps/pcyclerenv/local/lib/python2.7/site-packages/celery/__main__.py", line 30, in main
      main()
  
  (... exact same error as above ...)
  
  ImportError: No module named pcycler
  </code></pre>
  
  <p>I get the exact same error as what is in the error logs! This leads me to assume that the directory isn't properly changed when I am running in supervisor.</p>
  
  <p><strong>tldr</strong>: Why isn't the directory in my supervisor.conf being applied when I run the command using supervisorctl?</p>