title: Supervisor not working with Gunicorn + Flask
body: <p>I am trying to run Gunicorn from Supervisor in an Ubuntu 12.04 system. Gunicorn runs a Flask app (simple REST web service tested with Flask's embedded server). I have installed Gunicorn by clonning GIT repo, trying to avoid 'apt-get install' because it runs Gunicorn server when installs it. I do not want it running, it will be run by Supervisor only.</p>
  
  <p>So after install it, if I try:</p>
  
  <pre><code>cd /usr/local/bin
  gunicorn my_app:app -c /path/to/gu_config_file
  </code></pre>
  
  <p>Gunicorn works. Then I kill it. Note config file without extension, because with '.py' extension does not work for me. 
  So I edit Supervisor's config file like:</p>
  
  <pre><code>[program:gunicorn]
  command=/usr/local/bin/gunicorn my_app:app -c /path/to/.gu_setup
  directory=/usr/local/bin/
  autostart=true
  autorestart=true
  redirect_stderr=True
  </code></pre>
  
  <p>And update changes in Supervisor:</p>
  
  <pre><code>supervisorctl reread
  # gunicorn: changed
  supervisorctl update
  # gunicorn: stopped
  # gunicorn: updated process group
  </code></pre>
  
  <p>Detects changes in file and works for Gunicorn program. Ok, but then I try to start it:</p>
  
  <pre><code>supervisorctl start gunicorn
  </code></pre>
  
  <p>Getting an annoying:</p>
  
  <pre><code>gunicorn: ERROR (abnormal termination)
  </code></pre>
  
  <p>Checking supervisor's log:</p>
  
  <pre><code>2013-03-08 13:07:22,378 INFO spawned: 'gunicorn' with pid 3355
  2013-03-08 13:07:22,916 INFO exited: gunicorn (exit status 3; not expected)
  2013-03-08 13:07:23,918 INFO spawned: 'gunicorn' with pid 3361
  2013-03-08 13:07:24,492 INFO exited: gunicorn (exit status 3; not expected)
  2013-03-08 13:07:26,496 INFO spawned: 'gunicorn' with pid 3367
  2013-03-08 13:07:27,078 INFO exited: gunicorn (exit status 3; not expected)
  2013-03-08 13:07:30,085 INFO spawned: 'gunicorn' with pid 3373
  2013-03-08 13:07:30,628 INFO exited: gunicorn (exit status 3; not expected)
  2013-03-08 13:07:31,630 INFO gave up: gunicorn entered FATAL state, too many start retries too quickly
  </code></pre>
  
  <p>I do not know what to do right now... Can you help me?
  Thx a lot!</p>
  
  <p>EDIT: sorry I forgot to say I have exported PYTHONPATH variable as:</p>
  
  <pre><code>export PYTHONPATH=/usr/local/bin:/usr/local/lib/project
  </code></pre>
  
  <p>'my_app' is in /usr/local/bin. The lib path is needed for other modules.
  I have edited also Supervisor config file to indicate environmental variable, like:</p>
  
  <pre><code>environment=PYTHONPATH=/usr/local/bin:/usr/local/lib/project/
  </code></pre>
  
  <p>But did not work.</p>
  
  <p>EDIT 2: as @robertklep suggest in his comment, this is log's output:</p>
  
  <pre><code>Traceback (most recent call last):
    File "/tmp/gunicorn/gunicorn/arbiter.py", line 485, in spawn_worker
      worker.init_process()
    File "/tmp/gunicorn/gunicorn/workers/base.py", line 100, in init_process
      self.wsgi = self.app.wsgi()
    File "/tmp/gunicorn/gunicorn/app/base.py", line 103, in wsgi
      self.callable = self.load()
    File "/tmp/gunicorn/gunicorn/app/wsgiapp.py", line 25, in load
      return util.import_app(self.app_uri)
    File "/tmp/gunicorn/gunicorn/util.py", line 369, in import_app
      __import__(module)
    File "/usr/local/bin/my_app.py", line 4, in &lt;module&gt;
      import const
  ImportError: No module named const
  2013-03-08 13:29:35 [3670] [INFO] Worker exiting (pid: 3670)
  2013-03-08 13:29:36 [3665] [INFO] Shutting down: Master
  2013-03-08 13:29:36 [3665] [INFO] Reason: Worker failed to boot.
  </code></pre>
  
  <p>'const' module is in /usr/local/lib/project...</p>