heroku - Trying to run Django app on Gunicorn locally using Foreman -


i'm following getting started django on heroku tutorial
when i'm trying run django app on gunicorn using foreman, next error traceback:

09:23:33 web.1  | started pid 7012   09:23:34 web.1  | 2013-05-06 09:23:34 [7012] [info] starting gunicorn 0.17.2   09:23:34 web.1  | 2013-05-06 09:23:34 [7012] [info] listening at: `http://0.0.0.0:5000` (7012)   09:23:34 web.1  | 2013-05-06 09:23:34 [7012] [info] using worker: sync   09:23:34 web.1  | 2013-05-06 09:23:34 [7015] [info] booting worker pid: 7015   09:23:34 web.1  | 2013-05-06 09:23:34 [7015] [error] exception in worker process:   09:23:34 web.1  | traceback (most recent call last):   09:23:34 web.1  |   file "/usr/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 485, in spawn_worker   09:23:34 web.1  |     worker.init_process()   09:23:34 web.1  |   file "/usr/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 100, in init_process   09:23:34 web.1  |     self.wsgi = self.app.wsgi()   09:23:34 web.1  |   file "/usr/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 103, in wsgi   09:23:34 web.1  |     self.callable = self.load()   09:23:34 web.1  |   file "/usr/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 25, in load   09:23:34 web.1  |     return util.import_app(self.app_uri)   09:23:34 web.1  |   file "/usr/local/lib/python2.7/site-packages/gunicorn/util.py", line 372, in import_app   09:23:34 web.1  |     __import__(module)   09:23:34 web.1  |   file "/users/cosmicman66/djangodev/hepcat_server/hepcat_server/wsgi.py", line 27, in <module>   09:23:34 web.1  |     django.core.wsgi import get_wsgi_application   09:23:34 web.1  | importerror: no module named django.core.wsgi   09:23:34 web.1  | traceback (most recent call last):   09:23:34 web.1  |   file "/usr/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 485, in spawn_worker   09:23:34 web.1  |     worker.init_process()   09:23:34 web.1  |   file "/usr/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 100, in init_process   09:23:34 web.1  |     self.wsgi = self.app.wsgi()   09:23:34 web.1  |   file "/usr/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 103, in wsgi   09:23:34 web.1  |     self.callable = self.load()   09:23:34 web.1  |   file "/usr/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 25, in load   09:23:34 web.1  |     return util.import_app(self.app_uri)   09:23:34 web.1  |   file "/usr/local/lib/python2.7/site-packages/gunicorn/util.py", line 372, in import_app   09:23:34 web.1  |     __import__(module)   09:23:34 web.1  |   file "/users/cosmicman66/djangodev/hepcat_server/hepcat_server/wsgi.py", line 27, in <module>   09:23:34 web.1  |     django.core.wsgi import get_wsgi_application   09:23:34 web.1  | importerror: no module named django.core.wsgi   09:23:34 web.1  | 2013-05-06 09:23:34 [7015] [info] worker exiting (pid: 7015)   09:23:35 web.1  | 2013-05-06 09:23:35 [7012] [info] shutting down: master   09:23:35 web.1  | 2013-05-06 09:23:35 [7012] [info] reason: worker failed boot.   09:23:35 web.1  | exited code 3   09:23:35 system | sending sigterm processes   sigterm received 

procfile located in root directory of project , contains:

web: gunicorn hepcat_server.wsgi

settings.py located in hepcat_server directory

when use $ python manage.py run_gunicorn
gunicorn starts , see default django page

i had same issue while following heroku setup page using. found solution on this page. i've copied here posterity:

in root directory of django project, create procfile file. write on web: sh -c "cd djangoproject && gunicorn djangoproject.wsgi". create file called .env in same location, write django_settings_module=djangoproject.settings it, setting required env variable cannot set in djangoproject.wsgi module. run foreman start in order test. should self explanatory giving issue below.

when deploy, after creating application in heroku, set env variable command heroku config:set django_settings_module=djangoproject.settings, because deployment fails before file djangoproject/djangoproject/wsgi.py run.

remember replace "djangoproject" name of django project.


Comments