Django Heroku 应用程序错误。有啥不妥?
Posted
技术标签:
【中文标题】Django Heroku 应用程序错误。有啥不妥?【英文标题】:Django Heroku Application Error. Whats wrongs?Django Heroku 应用程序错误。有什么不妥? 【发布时间】:2017-09-04 00:48:00 【问题描述】:在 heroku 上运行我的 django 应用程序时出现应用程序错误。以下是 heroku 日志的结果:
2017-04-08T17:24:50.000000+00:00 app[api]: Build started by user anmol.gulati9513@gmail.com
2017-04-08T17:25:11.732420+00:00 app[api]: Deploy f4ef15f by user anmol.gulati9513@gmail.com
2017-04-08T17:25:11.732420+00:00 app[api]: Release v10 created by user anmol.gulati9513@gmail.com
2017-04-08T17:25:11.987358+00:00 app[api]: Release v10 created by user anmol.gulati9513@gmail.com
2017-04-08T17:24:50.000000+00:00 app[api]: Build succeeded
2017-04-08T17:25:12.354075+00:00 heroku[web.1]: State changed from crashed to starting
2017-04-08T17:25:18.683488+00:00 heroku[web.1]: Starting process with command `gunicorn --pythonpath expense_manager expense_manager.wsgi --log-file -`
2017-04-08T17:25:20.881565+00:00 heroku[web.1]: State changed from crashed to starting
2017-04-08T17:25:20.880602+00:00 heroku[web.1]: State changed from starting to crashed
2017-04-08T17:25:20.868145+00:00 heroku[web.1]: Process exited with status 3
2017-04-08T17:25:20.728492+00:00 app[web.1]: [2017-04-08 17:25:20 +0000] [4] [INFO] Starting gunicorn 19.7.1
2017-04-08T17:25:20.729017+00:00 app[web.1]: [2017-04-08 17:25:20 +0000] [4] [INFO] Listening at: http://0.0.0.0:38551 (4)
2017-04-08T17:25:20.729116+00:00 app[web.1]: [2017-04-08 17:25:20 +0000] [4] [INFO] Using worker: sync
2017-04-08T17:25:20.732466+00:00 app[web.1]: [2017-04-08 17:25:20 +0000] [8] [INFO] Booting worker with pid: 8
2017-04-08T17:25:20.736689+00:00 app[web.1]: [2017-04-08 17:25:20 +0000] [8] [ERROR] Exception in worker process
2017-04-08T17:25:20.736693+00:00 app[web.1]: Traceback (most recent call last):
2017-04-08T17:25:20.736694+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/arbiter.py", line 578, in spawn_worker
2017-04-08T17:25:20.736695+00:00 app[web.1]: worker.init_process()
2017-04-08T17:25:20.736696+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/workers/base.py", line 126, in init_process
2017-04-08T17:25:20.736697+00:00 app[web.1]: self.load_wsgi()
2017-04-08T17:25:20.736699+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/app/base.py", line 67, in wsgi
2017-04-08T17:25:20.736697+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/workers/base.py", line 135, in load_wsgi
2017-04-08T17:25:20.736698+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2017-04-08T17:25:20.736700+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
2017-04-08T17:25:20.736699+00:00 app[web.1]: self.callable = self.load()
2017-04-08T17:25:20.736701+00:00 app[web.1]: return self.load_wsgiapp()
2017-04-08T17:25:20.736701+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
2017-04-08T17:25:20.736703+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/util.py", line 352, in import_app
2017-04-08T17:25:20.736702+00:00 app[web.1]: return util.import_app(self.app_uri)
2017-04-08T17:25:20.736703+00:00 app[web.1]: __import__(module)
2017-04-08T17:25:20.736704+00:00 app[web.1]: ImportError: No module named 'expense_manager.wsgi'
2017-04-08T17:25:20.736798+00:00 app[web.1]: [2017-04-08 17:25:20 +0000] [8] [INFO] Worker exiting (pid: 8)
2017-04-08T17:25:20.780458+00:00 app[web.1]: [2017-04-08 17:25:20 +0000] [4] [INFO] Shutting down: Master
2017-04-08T17:25:20.780489+00:00 app[web.1]: [2017-04-08 17:25:20 +0000] [4] [INFO] Reason: Worker failed to boot.
2017-04-08T17:25:25.419069+00:00 heroku[web.1]: Starting process with command `gunicorn --pythonpath expense_manager expense_manager.wsgi --log-file -`
2017-04-08T17:25:27.653789+00:00 heroku[web.1]: Process exited with status 3
2017-04-08T17:25:27.664966+00:00 heroku[web.1]: State changed from starting to crashed
2017-04-08T17:25:27.418329+00:00 app[web.1]: [2017-04-08 17:25:27 +0000] [4] [INFO] Starting gunicorn 19.7.1
2017-04-08T17:25:27.428032+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/workers/base.py", line 135, in load_wsgi
2017-04-08T17:25:27.428038+00:00 app[web.1]: ImportError: No module named 'expense_manager.wsgi'
2017-04-08T17:25:27.465402+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2017-04-08T17:25:27.418976+00:00 app[web.1]: [2017-04-08 17:25:27 +0000] [4] [INFO] Using worker: sync
2017-04-08T17:25:27.428033+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2017-04-08T17:25:27.428182+00:00 app[web.1]: [2017-04-08 17:25:27 +0000] [8] [INFO] Worker exiting (pid: 8)
2017-04-08T17:25:27.465402+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/app/base.py", line 67, in wsgi
2017-04-08T17:25:27.422342+00:00 app[web.1]: [2017-04-08 17:25:27 +0000] [8] [INFO] Booting worker with pid: 8
2017-04-08T17:25:27.428033+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/app/base.py", line 67, in wsgi
2017-04-08T17:25:27.460499+00:00 app[web.1]: [2017-04-08 17:25:27 +0000] [9] [INFO] Booting worker with pid: 9
2017-04-08T17:25:27.465403+00:00 app[web.1]: self.callable = self.load()
2017-04-08T17:25:27.568119+00:00 app[web.1]: [2017-04-08 17:25:27 +0000] [4] [INFO] Reason: Worker failed to boot.
2017-04-08T17:25:27.418827+00:00 app[web.1]: [2017-04-08 17:25:27 +0000] [4] [INFO] Listening at: http://0.0.0.0:3650 (4)
2017-04-08T17:25:27.428033+00:00 app[web.1]: self.callable = self.load()
2017-04-08T17:25:27.465397+00:00 app[web.1]: [2017-04-08 17:25:27 +0000] [9] [ERROR] Exception in worker process
2017-04-08T17:25:27.465403+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
2017-04-08T17:25:27.428028+00:00 app[web.1]: [2017-04-08 17:25:27 +0000] [8] [ERROR] Exception in worker process
2017-04-08T17:25:27.428034+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
2017-04-08T17:25:27.465398+00:00 app[web.1]: Traceback (most recent call last):
2017-04-08T17:25:27.465404+00:00 app[web.1]: return self.load_wsgiapp()
2017-04-08T17:25:27.428030+00:00 app[web.1]: Traceback (most recent call last):
2017-04-08T17:25:27.428034+00:00 app[web.1]: return self.load_wsgiapp()
2017-04-08T17:25:27.465399+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/arbiter.py", line 578, in spawn_worker
2017-04-08T17:25:27.465404+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
2017-04-08T17:25:27.428031+00:00 app[web.1]: worker.init_process()
2017-04-08T17:25:27.428036+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/util.py", line 352, in import_app
2017-04-08T17:25:27.465401+00:00 app[web.1]: self.load_wsgi()
2017-04-08T17:25:27.465405+00:00 app[web.1]: __import__(module)
2017-04-08T17:25:27.428032+00:00 app[web.1]: self.load_wsgi()
2017-04-08T17:25:27.428036+00:00 app[web.1]: __import__(module)
2017-04-08T17:25:27.465401+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/workers/base.py", line 135, in load_wsgi
2017-04-08T17:25:27.465408+00:00 app[web.1]: ImportError: No module named 'expense_manager.wsgi'
2017-04-08T17:25:27.428030+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/arbiter.py", line 578, in spawn_worker
2017-04-08T17:25:27.428035+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
2017-04-08T17:25:27.465400+00:00 app[web.1]: worker.init_process()
2017-04-08T17:25:27.465404+00:00 app[web.1]: return util.import_app(self.app_uri)
2017-04-08T17:25:27.428031+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/workers/base.py", line 126, in init_process
2017-04-08T17:25:27.428035+00:00 app[web.1]: return util.import_app(self.app_uri)
2017-04-08T17:25:27.465400+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/workers/base.py", line 126, in init_process
2017-04-08T17:25:27.465405+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/util.py", line 352, in import_app
2017-04-08T17:25:27.465511+00:00 app[web.1]: [2017-04-08 17:25:27 +0000] [9] [INFO] Worker exiting (pid: 9)
2017-04-08T17:25:27.568035+00:00 app[web.1]: [2017-04-08 17:25:27 +0000] [4] [INFO] Shutting down: Master
2017-04-08T17:26:52.783836+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=expense-manager-django.herokuapp.com request_id=1d751f3f-b874-44d7-88f1-39996099aefa fwd="182.71.131.18" dyno= connect= service= status=503 bytes= protocol=https
2017-04-08T17:26:53.380252+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=expense-manager-django.herokuapp.com request_id=ffc9e5e0-040d-4eb7-ace9-261c42044a47 fwd="182.71.131.18" dyno= connect= service= status=503 bytes= protocol=https
请帮忙!我是使用heroku部署项目的新手。我真的不明白这些日志,所以如果有人能指出我正确的方向,我将不胜感激。
├── accounts
│ ├── admin.py
│ ├── __init__.py
│ ├── migrations
│ ├── models.py
│ ├── __pycache__
│ ├── templates
│ ├── tests.py
│ ├── urls.py
│ └── views.py
├── assets
│ ├── css
│ └── js
├── db.sqlite3
├── expense
│ ├── admin.py
│ ├── __init__.py
│ ├── migrations
│ ├── models.py
│ ├── __pycache__
│ ├── serializers.py
│ ├── static
│ ├── templates
│ ├── tests.py
│ ├── urls.py
│ └── views.py
├── expense_manager
│ ├── __init__.py
│ ├── __pycache__
│ ├── settings.py
│ ├── urls.py
│ ├── views.py
│ └── wsgi.py
├── manage.py
├── Procfile
├── requirements.txt
├── runtime.txt
└── templates
├── base.html
├── home.html
└── welcome.html
这里,我也贴了树
【问题讨论】:
您几乎可以肯定不应该使用--python-path
参数。
现在它说 Failed to find application: 'expense_manager' @DanielRoseman
你的文件树是什么样的? ***.com/a/19671818/6085135
w - 费用管理器(主项目文件夹包含所有应用程序和 manage.py 文件等) requirements.txt Procfile runtime.txt @bren
这是预期的文件结构github.com/heroku/python-getting-started也许你可以向我们展示你的文件树tree -L 2
***.com/questions/3455625/…
【参考方案1】:
为您的 Procfile 尝试:
web: gunicorn --pythonpath expense_manager wsgi
这基本上等同于你的跑步方式:
python expense_manager/wsgi.py
Gunicorn 的--pythonpath
参数允许您指定目录、包名甚至模块。像这样:
gunicorn --pythonpath <directory> <package>.<module>
【讨论】:
您的.git
文件夹在哪里?运行ls -a
也可能仔细检查它不是python-path
哥们你是救世主
哇哦谢谢!现在让我忘记我在找到这个之前浪费的所有时间!以上是关于Django Heroku 应用程序错误。有啥不妥?的主要内容,如果未能解决你的问题,请参考以下文章
Django/Celery 和 CloudAMQP/Heroku 的连接错误
我想在 Heroku 上部署一个 Django 应用程序,但出现错误