简体   繁体   中英

Can't deploy to Heroku in DjangoGirls tutorial

I am following this DjangoGirls tutorial: http://tutorial.djangogirls.org/en/deploy/README.html

When I try and open my app's /admin page, since the tutorial states:

"Since we only created the admin view for the app so far, add admin/ to the url (eg https://djangogirlsblog.herokuapp.com/admin/ ) to see a working page of our web app."

I still get the following browser message:

Application Error An error occurred in the application and your page could not be served. Please try again in a few moments.

If you are the application owner, check your logs for details.

This is my project layout:

djangogirls
|--mysite/
  |--blog/
  |--db.sqlite3
  |----manage.py
  |----mysite/
|--myvenv/
|--Procfile
|--requirements.txt
|--runtime.txt
|--.gitignore

These are the contents of .gitignore:

myvenv
__pycache__
staticfiles
local_settings.py
db.sqlite3
*.py[co]
*.pyc

These are the contents of my mysite/wsgi.py

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")

application = get_wsgi_application()

from whitenoise.django import DjangoWhiteNoise
application = DjangoWhiteNoise(application)

These are the contents of Procfile are

web: gunicorn djangogirls.wsgi

The tutorial tells us to copy out mysite.wsgi, but I saw in another post that it should be the project_name.wsgi, so I changed this.

runtime.txt: python-2.7.6

requirements.txt:

dj-database-url==0.3.0
Django==1.8
gunicorn==19.3.0
whitenoise==1.0.6
psycopg2==2.5.4

I know this is a long post and I apologize for that in advance, I want to provide more information rather than not enough, and I do not entirely understand what are the important things I should be looking at in this situation!

This is my heroku logs:

2015-04-07T02:30:18.990628+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 189, in run
2015-04-07T02:30:18.990685+00:00 app[web.1]:     super(Application, self).run()
2015-04-07T02:30:18.990710+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 72, in run
2015-04-07T02:30:18.990746+00:00 app[web.1]:     Arbiter(self).run()
2015-04-07T02:30:18.990823+00:00 app[web.1]:     self.manage_workers()
2015-04-07T02:30:19.728739+00:00 heroku[web.1]: Process exited with status 1
2015-04-07T02:30:19.750144+00:00 heroku[web.1]: State changed from starting to crashed
2015-04-07T02:30:19.750381+00:00 heroku[web.1]: State changed from crashed to starting
2015-04-07T02:30:22.860260+00:00 heroku[web.1]: Starting process with command `gunicorn djangogirls.wsgi`
2015-04-07T02:30:24.130180+00:00 app[web.1]: [2015-04-07 02:30:24 +0000] [3] [INFO] Listening at: http://0.0.0.0:24389 (3)
2015-04-07T02:30:24.137056+00:00 app[web.1]: [2015-04-07 02:30:24 +0000] [9] [INFO] Booting worker with pid: 9
2015-04-07T02:30:24.170773+00:00 app[web.1]: Traceback (most recent call last):
2015-04-07T02:30:24.170770+00:00 app[web.1]: [2015-04-07 02:30:24 +0000] [10] [ERROR] Exception in worker process:
2015-04-07T02:30:24.170775+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 507, in spawn_worker
2015-04-07T02:30:24.170777+00:00 app[web.1]:     worker.init_process()
2015-04-07T02:30:24.130312+00:00 app[web.1]: [2015-04-07 02:30:24 +0000] [3] [INFO] Using worker: sync
2015-04-07T02:30:24.170780+00:00 app[web.1]:     self.wsgi = self.app.wsgi()
2015-04-07T02:30:24.170778+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/base.py", line 118, in init_process
2015-04-07T02:30:24.170791+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/util.py", line 355, in import_app
2015-04-07T02:30:24.170792+00:00 app[web.1]:     __import__(module)
2015-04-07T02:30:24.170783+00:00 app[web.1]:     self.callable = self.load()
2015-04-07T02:30:24.170784+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
2015-04-07T02:30:24.170786+00:00 app[web.1]:     return self.load_wsgiapp()
2015-04-07T02:30:24.170798+00:00 app[web.1]:     worker.init_process()
2015-04-07T02:30:24.170793+00:00 app[web.1]: ImportError: No module named djangogirls.wsgi
2015-04-07T02:30:24.170795+00:00 app[web.1]: Traceback (most recent call last):
2015-04-07T02:30:24.170796+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 507, in spawn_worker
2015-04-07T02:30:24.170788+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
2015-04-07T02:30:24.170789+00:00 app[web.1]:     return util.import_app(self.app_uri)
2015-04-07T02:30:24.170806+00:00 app[web.1]:     return self.load_wsgiapp()
2015-04-07T02:30:24.170807+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
2015-04-07T02:30:24.170808+00:00 app[web.1]:     return util.import_app(self.app_uri)
2015-04-07T02:30:24.170799+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/base.py", line 118, in init_process
2015-04-07T02:30:24.170811+00:00 app[web.1]:     __import__(module)
2015-04-07T02:30:24.170802+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
2015-04-07T02:30:24.170803+00:00 app[web.1]:     self.callable = self.load()
2015-04-07T02:30:24.170804+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
2015-04-07T02:30:24.170800+00:00 app[web.1]:     self.wsgi = self.app.wsgi()
2015-04-07T02:30:24.170781+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
2015-04-07T02:30:24.176154+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 189, in run
2015-04-07T02:30:24.176159+00:00 app[web.1]:     Arbiter(self).run()
2015-04-07T02:30:24.176144+00:00 app[web.1]: Traceback (most recent call last):
2015-04-07T02:30:24.176162+00:00 app[web.1]:     self.manage_workers()
2015-04-07T02:30:24.176151+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 74, in run
2015-04-07T02:30:24.176168+00:00 app[web.1]:     time.sleep(0.1 * random.random())
2015-04-07T02:30:24.176153+00:00 app[web.1]:     WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
2015-04-07T02:30:24.176156+00:00 app[web.1]:     super(Application, self).run()
2015-04-07T02:30:24.170877+00:00 app[web.1]: [2015-04-07 02:30:24 +0000] [10] [INFO] Worker exiting (pid: 10)
2015-04-07T02:30:24.176163+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 477, in manage_workers
2015-04-07T02:30:24.176148+00:00 app[web.1]:   File "/app/.heroku/python/bin/gunicorn", line 11, in <module>
2015-04-07T02:30:24.176165+00:00 app[web.1]:     self.spawn_workers()
2015-04-07T02:30:24.176149+00:00 app[web.1]:     sys.exit(run())
2015-04-07T02:30:24.176166+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 541, in spawn_workers
2015-04-07T02:30:24.170813+00:00 app[web.1]: ImportError: No module named djangogirls.wsgi
2015-04-07T02:30:24.176161+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 174, in run
2015-04-07T02:30:24.178515+00:00 app[web.1]: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
2015-04-07T02:30:24.170810+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/util.py", line 355, in import_app
2015-04-07T02:30:24.176158+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 72, in run
2015-04-07T02:30:24.178505+00:00 app[web.1]:     raise HaltServer(reason, self.WORKER_BOOT_ERROR)
2015-04-07T02:30:24.141236+00:00 app[web.1]:     self.callable = self.load()
2015-04-07T02:30:24.176170+00:00 app[web.1]:     self.reap_workers()
2015-04-07T02:30:24.176169+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 214, in handle_chld
2015-04-07T02:30:24.176172+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 459, in reap_workers
2015-04-07T02:30:24.141232+00:00 app[web.1]:     self.wsgi = self.app.wsgi()
2015-04-07T02:30:24.141237+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
2015-04-07T02:30:24.141239+00:00 app[web.1]:     return self.load_wsgiapp()
2015-04-07T02:30:24.141254+00:00 app[web.1]:     self.wsgi = self.app.wsgi()
2015-04-07T02:30:24.141229+00:00 app[web.1]:     worker.init_process()
2015-04-07T02:30:24.129374+00:00 app[web.1]: [2015-04-07 02:30:24 +0000] [3] [INFO] Starting gunicorn 19.3.0
2015-04-07T02:30:24.141223+00:00 app[web.1]: [2015-04-07 02:30:24 +0000] [9] [ERROR] Exception in worker process:
2015-04-07T02:30:24.141231+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/base.py", line 118, in init_process
2015-04-07T02:30:24.141246+00:00 app[web.1]: ImportError: No module named djangogirls.wsgi
2015-04-07T02:30:24.141228+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 507, in spawn_worker
2015-04-07T02:30:24.141248+00:00 app[web.1]: Traceback (most recent call last):
2015-04-07T02:30:24.141226+00:00 app[web.1]: Traceback (most recent call last):
2015-04-07T02:30:24.141251+00:00 app[web.1]:     worker.init_process()
2015-04-07T02:30:24.141234+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
2015-04-07T02:30:24.141252+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/base.py", line 118, in init_process
2015-04-07T02:30:24.141240+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
2015-04-07T02:30:24.141249+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 507, in spawn_worker
2015-04-07T02:30:24.141242+00:00 app[web.1]:     return util.import_app(self.app_uri)
2015-04-07T02:30:24.141243+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/util.py", line 355, in import_app
2015-04-07T02:30:24.141244+00:00 app[web.1]:     __import__(module)
2015-04-07T02:30:24.141262+00:00 app[web.1]:     return util.import_app(self.app_uri)
2015-04-07T02:30:24.141256+00:00 app[web.1]:     self.callable = self.load()
2015-04-07T02:30:24.141259+00:00 app[web.1]:     return self.load_wsgiapp()
2015-04-07T02:30:24.141263+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/util.py", line 355, in import_app
2015-04-07T02:30:24.141255+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
2015-04-07T02:30:24.141258+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
2015-04-07T02:30:24.141260+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
2015-04-07T02:30:24.166744+00:00 app[web.1]: [2015-04-07 02:30:24 +0000] [10] [INFO] Booting worker with pid: 10
2015-04-07T02:30:24.141264+00:00 app[web.1]:     __import__(module)
2015-04-07T02:30:24.141266+00:00 app[web.1]: ImportError: No module named djangogirls.wsgi
2015-04-07T02:30:24.141324+00:00 app[web.1]: [2015-04-07 02:30:24 +0000] [9] [INFO] Worker exiting (pid: 9)
2015-04-07T02:30:24.956327+00:00 heroku[web.1]: State changed from starting to crashed
2015-04-07T02:30:24.942505+00:00 heroku[web.1]: Process exited with status 1
2015-04-07T02:30:39.168025+00:00 heroku[api]: Scale to web=1 by paulzovighian@gmail.com
2015-04-07T02:30:45.176867+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=jtestblog.herokuapp.com request_id=457b2a51-1fc2-4f83-8316-c8fb0635c97b fwd="67.70.37.25" dyno= connect= service= status=503 bytes=
2015-04-07T02:30:48.582173+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=jtestblog.herokuapp.com request_id=137c668e-8d93-4c14-b98d-d1737adabf97 fwd="67.70.37.25" dyno= connect= service= status=503 bytes=
2015-04-07T02:30:48.976617+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/admin/" host=jtestblog.herokuapp.com request_id=8ad477b3-4348-4a90-b7bf-53791d7c5e02 fwd="67.70.37.25" dyno= connect= service= status=503 bytes=
2015-04-07T02:30:54.502759+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/admin/" host=jtestblog.herokuapp.com request_id=c074764e-4ac9-4205-8762-8073bf3cd7d6 fwd="67.70.37.25" dyno= connect= service= status=503 bytes=

It seems like this is one of the tougher stages of the tutorial, and I just can't seem to figure out what this error means exactly... Thanks in advance to anyone who can help, I really appreciate it!

If you project folder inside the root then you have to give exact path so gunicorn will server better ..:)

like web: gunicorn --pythonpath app app.wsgi

for more info pythonpath

The problem is in your Procfile. The instructions say to do:

web: gunicorn mysite.wsgi

but you have put "djangogirls" instead of "mysite". As you explained in the comments, your project is actually called "mysite", and "djangogirls" is simply the name of the containing folder.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM