I'm trying to deploy an app that I started with django-admin startproject workout
. Months later, it was time to deploy, workout
was not an available name for heroku apps. Thus, I decided on shworkout
. Now, I'm having problems with the deployment. Take a look at this traceback:
2018-01-15T13:50:49.922410+00:00 heroku[web.1]: Starting process with command `gunicorn shworkout.wsgi --log-file -`
2018-01-15T13:50:52.274803+00:00 app[web.1]: [2018-01-15 13:50:52 +0000] [4] [INFO] Starting gunicorn 19.7.1
2018-01-15T13:50:52.275393+00:00 app[web.1]: [2018-01-15 13:50:52 +0000] [4] [INFO] Listening at: http://0.0.0.0:57296 (4)
2018-01-15T13:50:52.275484+00:00 app[web.1]: [2018-01-15 13:50:52 +0000] [4] [INFO] Using worker: sync
2018-01-15T13:50:52.278566+00:00 app[web.1]: [2018-01-15 13:50:52 +0000] [8] [INFO] Booting worker with pid: 8
2018-01-15T13:50:52.283407+00:00 app[web.1]: [2018-01-15 13:50:52 +0000] [8] [ERROR] Exception in worker process
2018-01-15T13:50:52.283421+00:00 app[web.1]: Traceback (most recent call last):
2018-01-15T13:50:52.283428+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 578, in spawn_worker
2018-01-15T13:50:52.283430+00:00 app[web.1]: worker.init_process()
2018-01-15T13:50:52.283431+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 126, in init_process
2018-01-15T13:50:52.283433+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 135, in load_wsgi
2018-01-15T13:50:52.283432+00:00 app[web.1]: self.load_wsgi()
2018-01-15T13:50:52.283434+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2018-01-15T13:50:52.283443+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
2018-01-15T13:50:52.283441+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
2018-01-15T13:50:52.283442+00:00 app[web.1]: self.callable = self.load()
2018-01-15T13:50:52.283446+00:00 app[web.1]: return util.import_app(self.app_uri)
2018-01-15T13:50:52.283448+00:00 app[web.1]: __import__(module)
2018-01-15T13:50:52.283444+00:00 app[web.1]: return self.load_wsgiapp()
2018-01-15T13:50:52.283445+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
2018-01-15T13:50:52.283449+00:00 app[web.1]: ModuleNotFoundError: No module named 'shworkout'
2018-01-15T13:50:52.315187+00:00 app[web.1]: [2018-01-15 13:50:52 +0000] [4] [INFO] Reason: Worker failed to boot.
2018-01-15T13:50:52.283447+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/util.py", line 352, in import_app
2018-01-15T13:50:52.283527+00:00 app[web.1]: [2018-01-15 13:50:52 +0000] [8] [INFO] Worker exiting (pid: 8)
2018-01-15T13:50:52.315111+00:00 app[web.1]: [2018-01-15 13:50:52 +0000] [4] [INFO] Shutting down: Master
2018-01-15T13:50:52.401600+00:00 heroku[web.1]: Process exited with status 3
2018-01-15T13:50:52.415493+00:00 heroku[web.1]: State changed from starting to crashed
The lines
File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
2018-01-15T13:50:52.283449+00:00 app[web.1]: ModuleNotFoundError: No module named 'shworkout'
are what catch my attention the most. My guess is this: gunicorn is looking for a wsgi.py file (it's in /workout
), but it's looking for it in the wrong place, namely, a folder called /shworkout
. Such a folder doesn't exist in my project. shworkout
is only a name for my app on heroku .
So, is this a correct explanation? What to do about it then? And if I'm wrong, what is really going on here?
Procfile :
web: gunicorn shworkout.wsgi --log-file -
Should I change shworkout
to workout
?
wsgi.py :
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "workout.settings.production")
application = get_wsgi_application()
I was using a faulty Procfile. Changed from:
web: gunicorn shworkout.wsgi --log-file -
to
web: gunicorn workout.wsgi --log-file -
Explanation:
the Procfile should point to the location of the wsgi.py file, which is in /workout
, not in /shworkout
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.