Reputation: 425
-Mac OSX 10.7.5 -Python 2.7 -PostgreSQL 9.3.2 (set up via Heroku) -Django 1.6
I get an "Application Error" message when I go to the site url. I do have a mysite/wsgi.py file and here's what's in it:
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")
from django.core.wsgi import get_wsgi_application
from dj_static import Cling
application = Cling(get_wsgi_application())
My Procfile contains
web: gunicorn mysite.wsgi
When I run "foreman start", I get:
23:53:02 web.1 | started with pid 709
23:53:02 web.1 | /usr/local/foreman/bin/foreman-runner: line 41: exec: gunicorn: not found
23:53:02 web.1 | exited with code 127
23:53:02 system | sending SIGTERM to all processes
SIGTERM received
"Heroku logs" gives me:
logs
2014-01-28T11:08:04.245169+00:00 app[web.1]: __import__(module)
2014-01-28T11:08:04.244817+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/util.py", line 354, in import_app
2014-01-28T11:08:04.245169+00:00 app[web.1]: self.callable = self.load()
2014-01-28T11:08:04.245169+00:00 app[web.1]: ImportError: No module named mysite.wsgi
2014-01-28T11:08:04.459583+00:00 app[web.1]: 2014-01-28 11:08:04 [2] [INFO] Shutting down: Master
2014-01-28T11:08:04.459583+00:00 app[web.1]: 2014-01-28 11:08:04 [2] [INFO] Reason: Worker failed to boot.
2014-01-28T11:08:05.967655+00:00 heroku[web.1]: Process exited with status 3
2014-01-28T11:08:06.021577+00:00 heroku[web.1]: State changed from starting to crashed
2014-01-28T13:17:57.938033+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=nodemotion.herokuapp.com request_id=823e63b7-c67c-4d30-a610-3539d8996603 fwd="10.6.129.117, 199.204.164.130" dyno= connect= service= status=503 bytes=
2014-01-28T14:33:28.424579+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=nodemotion.herokuapp.com request_id=be5be364-68d6-49cb-bdd8-47acc4dc7187 fwd="10.6.129.117, 199.204.164.130" dyno= connect= service= status=503 bytes=
2014-01-28T16:43:37.500012+00:00 heroku[web.1]: State changed from crashed to starting
2014-01-28T16:43:42.430719+00:00 heroku[web.1]: Starting process with command `gunicorn mysite.wsgi`
2014-01-28T16:43:43.781315+00:00 app[web.1]: 2014-01-28 16:43:43 [2] [INFO] Using worker: sync
2014-01-28T16:43:43.780648+00:00 app[web.1]: 2014-01-28 16:43:43 [2] [INFO] Starting gunicorn 18.0
201
4-01-28T16:43:43.781237+00:00 app[web.1]: 2014-01-28 16:43:43 [2] [INFO] Listening at: http://0.0.0.0:49328 (2)
2014-01-28T16:43:43.793707+00:00 app[web.1]: 2014-01-28 16:43:43 [7] [INFO] Booting worker with pid: 7
2014-01-28T16:43:43.798827+00:00 app[web.1]: 2014-01-28 16:43:43 [7] [ERROR] Exception in worker process:
2014-01-28T16:43:43.798827+00:00 app[web.1]: Traceback (most recent call last):
2014-01-28T16:43:43.798827+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 495, in spawn_worker
2014-01-28T16:43:43.799160+00:00 app[web.1]: 2014-01-28 16:43:43 [7] [INFO] Worker exiting (pid: 7)
2014-01-28T16:43:43.798827+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/base.py", line 106, in init_process
2014-01-28T16:43:43.798827+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2014-01-28T16:43:43.798827+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 114, in wsgi
2014-01-28T16:43:43.799021+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/util.py", line 354, in import_app
2014-01-28T16:43:43.799021+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 49, in load_wsgiapp
2014-01-28T16:43:43.798827+00:00 app[web.1]: worker.init_process()
2014-01-28T16:43:43.798827+00:00 app[web.1]: return self.load_wsgiapp()
2014-01-28T16:43:43.798827+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 62, in load
2014-01-28T16:43:43.798827+00:00 app[web.1]: self.callable = self.load()
2014-01-28T16:43:43.799021+00:00 app[web.1]: return util.import_app(self.app_uri)
2014-01-28T16:43:43.799021+00:00 app[web.1]: __import__(module)
2014-01-28T16:43:43.799021+00:00 app[web.1]: ImportError: No module named mysite.wsgi
2014-01-28T16:43:43.799160+00:00 app[web.1]: self.callable = self.load()
2014-01-28T16:43:43.799160+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 114, in wsgi
2014-01-28T16:43:43.799021+00:00 app[web.1]: Traceback (most recent call last):
2014-01-28T16:43:43.799021+00:00 app[web.1]: worker.init_process()
2014-01-28T16:43:43.799021+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/base.py", line 106, in init_process
2014-01-28T16:43:43.799021+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 495, in spawn_worker
2014-01-28T16:43:43.799021+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2014-01-28T16:43:43.799160+00:00 app[web.1]: __import__
From the "foreman start" results, I gathered that perhaps gunicorn wasn't properly installed, so I downloaded a .gz and did "sudo python setup.py install" and "import gunicorn" showed that it installed properly. Then I did "git push heroku" once again, but I'm still getting the same error. Does anybody have insight into what might be going on here? thnx.
Upvotes: 2
Views: 4623
Reputation: 425
The issue, it turns out was that I had added the init.py file in my app folder to .gitignore. As a result django wasn't recognizing my app folder as a module, hence the import error. Removing the init.py file from .gitignore resolved the issue.
Upvotes: 2