工人无法启动

时间:2018-03-15 18:42:30

标签: python django heroku deployment gunicorn

我试图在Heroku上部署我的Django项目,但出现了问题,我无法知道发生了什么,以及为了解决这个问题该怎么做。我在其他帖子中读到这个问题可能与Gunicorn有关,但我无法解决。

(env) ignacio@ignacio:~/atletico$ heroku logs
2018-03-15T18:04:33.770218+00:00 app[web.1]: [2018-03-15 18:04:33 +0000] [4] [INFO] Reason: Worker failed to boot.
2018-03-15T18:04:47.082000+00:00 heroku[web.1]: Starting process with command `gunicorn mysite.wsgi --log-file -`
2018-03-15T18:04:49.411412+00:00 heroku[web.1]: Process exited with status 3
2018-03-15T18:04:49.139027+00:00 app[web.1]: [2018-03-15 18:04:49 +0000] [4] [INFO] Starting gunicorn 19.7.1
2018-03-15T18:04:49.139593+00:00 app[web.1]: [2018-03-15 18:04:49 +0000] [4] [INFO] Listening at: http://0.0.0.0:25381 (4)
2018-03-15T18:04:49.139786+00:00 app[web.1]: [2018-03-15 18:04:49 +0000] [4] [INFO] Using worker: sync
2018-03-15T18:04:49.149373+00:00 app[web.1]: [2018-03-15 18:04:49 +0000] [8] [ERROR] Exception in worker process
2018-03-15T18:04:49.149376+00:00 app[web.1]: Traceback (most recent call last):
2018-03-15T18:04:49.149391+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 578, in spawn_worker
2018-03-15T18:04:49.149394+00:00 app[web.1]:     worker.init_process()
2018-03-15T18:04:49.143828+00:00 app[web.1]: [2018-03-15 18:04:49 +0000] [8] [INFO] Booting worker with pid: 8
2018-03-15T18:04:49.149396+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 126, in init_process
2018-03-15T18:04:49.149398+00:00 app[web.1]:     self.load_wsgi()
2018-03-15T18:04:49.149400+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 135, in load_wsgi
2018-03-15T18:04:49.149401+00:00 app[web.1]:     self.wsgi = self.app.wsgi()
2018-03-15T18:04:49.149408+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
2018-03-15T18:04:49.149411+00:00 app[web.1]:     self.callable = self.load()
2018-03-15T18:04:49.149413+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
2018-03-15T18:04:49.149416+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
2018-03-15T18:04:49.149418+00:00 app[web.1]:     return util.import_app(self.app_uri)
2018-03-15T18:04:49.149414+00:00 app[web.1]:     return self.load_wsgiapp()
2018-03-15T18:04:49.149422+00:00 app[web.1]:     __import__(module)
2018-03-15T18:04:49.149420+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/util.py", line 352, in import_app
2018-03-15T18:04:49.149513+00:00 app[web.1]: [2018-03-15 18:04:49 +0000] [8] [INFO] Worker exiting (pid: 8)
2018-03-15T18:04:49.154811+00:00 app[web.1]: [2018-03-15 18:04:49 +0000] [9] [INFO] Booting worker with pid: 9
2018-03-15T18:04:49.149424+00:00 app[web.1]: ModuleNotFoundError: No module named 'mysite.wsgi'
2018-03-15T18:04:49.163852+00:00 app[web.1]: [2018-03-15 18:04:49 +0000] [9] [ERROR] Exception in worker process
2018-03-15T18:04:49.163856+00:00 app[web.1]: Traceback (most recent call last):
2018-03-15T18:04:49.163860+00:00 app[web.1]:     worker.init_process()
2018-03-15T18:04:49.163858+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 578, in spawn_worker
2018-03-15T18:04:49.163862+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 126, in init_process
2018-03-15T18:04:49.163863+00:00 app[web.1]:     self.load_wsgi()
2018-03-15T18:04:49.163865+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 135, in load_wsgi
2018-03-15T18:04:49.163867+00:00 app[web.1]:     self.wsgi = self.app.wsgi()
2018-03-15T18:04:49.163869+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
2018-03-15T18:04:49.163871+00:00 app[web.1]:     self.callable = self.load()
2018-03-15T18:04:49.163872+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
2018-03-15T18:04:49.163876+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
2018-03-15T18:04:49.163878+00:00 app[web.1]:     return util.import_app(self.app_uri)
2018-03-15T18:04:49.163874+00:00 app[web.1]:     return self.load_wsgiapp()
2018-03-15T18:04:49.163881+00:00 app[web.1]:     __import__(module)
2018-03-15T18:04:49.163880+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/util.py", line 352, in import_app
2018-03-15T18:04:49.164035+00:00 app[web.1]: [2018-03-15 18:04:49 +0000] [9] [INFO] Worker exiting (pid: 9)
2018-03-15T18:04:49.308012+00:00 app[web.1]: [2018-03-15 18:04:49 +0000] [4] [INFO] Shutting down: Master
2018-03-15T18:04:49.163889+00:00 app[web.1]: ModuleNotFoundError: No module named 'mysite.wsgi'
2018-03-15T18:04:49.308186+00:00 app[web.1]: [2018-03-15 18:04:49 +0000] [4] [INFO] Reason: Worker failed to boot.
2018-03-15T18:04:49.754383+00:00 heroku[web.1]: State changed from starting to crashed

wsgi.py

`
"""
WSGI config for mysite project.

It exposes the WSGI callable as a module-level variable named 
application.

For more information on this file, see
https://docs.djangoproject.com/en/2.0/howto/deployment/wsgi/
"""
import os

from django.core.wsgi import get_wsgi_application

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

application = get_wsgi_application()

2 个答案:

答案 0 :(得分:0)

你的gunicorn start命令看起来很奇怪:

Starting process with command `gunicorn mysite.wsgi --log-file -`

该命令应指定用冒号分隔的模块名称和变量名称,如下所示:

gunicorn mysite.wsgi:application

答案 1 :(得分:0)

<强> SOLUTION:

问题是我的Procfile文件的位置:它必须与manage.py位于同一路径上。这就是全部!