当我将django应用程序部署到heroku时,该站点停止工作

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了当我将django应用程序部署到heroku时,该站点停止工作相关的知识,希望对你有一定的参考价值。

我已经完成了YouTube教程(https://www.youtube.com/watch?v=MoX36izzEWY)之后的所有操作,而且还不错,但是当我将项目推送到heroku时,站点停止工作,并且当我运行heroku logs --tail命令时,它给了我:

2019-12-01T11:40:18.921974+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/util.py", line 358, in import_app
2019-12-01T11:40:18.921976+00:00 app[web.1]: mod = importlib.import_module(module)
2019-12-01T11:40:18.921978+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/importlib/__init__.py", line 126, in import_module
2019-12-01T11:40:18.921980+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2019-12-01T11:40:18.921982+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 994, in _gcd_import
2019-12-01T11:40:18.921984+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 971, in _find_and_load
2019-12-01T11:40:18.921986+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 941, in _find_and_load_unlocked
2019-12-01T11:40:18.921988+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
2019-12-01T11:40:18.921990+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 994, in _gcd_import
2019-12-01T11:40:18.921992+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 971, in _find_and_load
2019-12-01T11:40:18.921994+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
2019-12-01T11:40:18.922001+00:00 app[web.1]: ModuleNotFoundError: No module named 'BlogProject'
2019-12-01T11:40:18.922117+00:00 app[web.1]: [2019-12-01 11:40:18 +0000] [10] [INFO] Worker exiting (pid: 10)
2019-12-01T11:40:18.950480+00:00 app[web.1]: [2019-12-01 11:40:18 +0000] [4] [INFO] Shutting down: Master
2019-12-01T11:40:18.950634+00:00 app[web.1]: [2019-12-01 11:40:18 +0000] [4] [INFO] Reason: Worker failed to boot.
2019-12-01T11:40:19.030596+00:00 heroku[web.1]: Process exited with status 3
2019-12-01T11:40:21.000000+00:00 app[api]: Build succeeded
2019-12-01T11:40:24.514282+00:00 heroku[web.1]: Starting process with command `gunicorn BlogProject.wsgi`
2019-12-01T11:40:27.042695+00:00 heroku[web.1]: State changed from starting to crashed
2019-12-01T11:40:26.888453+00:00 app[web.1]: [2019-12-01 11:40:26 +0000] [4] [INFO] Starting gunicorn 20.0.4
2019-12-01T11:40:26.889134+00:00 app[web.1]: [2019-12-01 11:40:26 +0000] [4] [INFO] Listening at: http://0.0.0.0:51267 (4)
2019-12-01T11:40:26.889243+00:00 app[web.1]: [2019-12-01 11:40:26 +0000] [4] [INFO] Using worker: sync
2019-12-01T11:40:26.893921+00:00 app[web.1]: [2019-12-01 11:40:26 +0000] [10] [INFO] Booting worker with pid: 10
2019-12-01T11:40:26.901275+00:00 app[web.1]: [2019-12-01 11:40:26 +0000] [10] [ERROR] Exception in worker process
2019-12-01T11:40:26.901279+00:00 app[web.1]: Traceback (most recent call last):
2019-12-01T11:40:26.901282+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
2019-12-01T11:40:26.901284+00:00 app[web.1]: worker.init_process()
2019-12-01T11:40:26.901286+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 119, in init_process
2019-12-01T11:40:26.901288+00:00 app[web.1]: self.load_wsgi()
2019-12-01T11:40:26.901290+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 144, in load_wsgi
2019-12-01T11:40:26.901292+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2019-12-01T11:40:26.901295+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
2019-12-01T11:40:26.901296+00:00 app[web.1]: self.callable = self.load()
2019-12-01T11:40:26.901299+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 49, in load
2019-12-01T11:40:26.901301+00:00 app[web.1]: return self.load_wsgiapp()
2019-12-01T11:40:26.901303+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp
2019-12-01T11:40:26.901305+00:00 app[web.1]: return util.import_app(self.app_uri)
2019-12-01T11:40:26.901307+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/util.py", line 358, in import_app
2019-12-01T11:40:26.901309+00:00 app[web.1]: mod = importlib.import_module(module)
2019-12-01T11:40:26.901311+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/importlib/__init__.py", line 126, in import_module
2019-12-01T11:40:26.901314+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2019-12-01T11:40:26.901316+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 994, in _gcd_import
2019-12-01T11:40:26.901318+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 971, in _find_and_load
2019-12-01T11:40:26.901320+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 941, in _find_and_load_unlocked
2019-12-01T11:40:26.901322+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
2019-12-01T11:40:26.901324+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 994, in _gcd_import
2019-12-01T11:40:26.901326+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 971, in _find_and_load
2019-12-01T11:40:26.901328+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
2019-12-01T11:40:26.901384+00:00 app[web.1]: ModuleNotFoundError: No module named 'BlogProject'
2019-12-01T11:40:26.901556+00:00 app[web.1]: [2019-12-01 11:40:26 +0000] [10] [INFO] Worker exiting (pid: 10)
2019-12-01T11:40:26.941159+00:00 app[web.1]: [2019-12-01 11:40:26 +0000] [4] [INFO] Shutting down: Master
2019-12-01T11:40:26.941411+00:00 app[web.1]: [2019-12-01 11:40:26 +0000] [4] [INFO] Reason: Worker failed to boot.
2019-12-01T11:40:27.023360+00:00 heroku[web.1]: Process exited with status 3
2019-12-01T11:40:31.959066+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=theblogformamad.herokuapp.com request_id=0fce1c3e-4852-430a-b5da-cdb9216e1f69 fwd="23.111.188.5" dyno= connect= service= status=503 bytes= protocol=http
2019-12-01T11:40:35.412807+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=theblogformamad.herokuapp.com request_id=977b8a12-3cde-4391-8b70-1df1b5fa1ecd fwd="23.111.188.5" dyno= connect= service= status=503 bytes= protocol=http
2019-12-01T12:09:38.519146+00:00 heroku[web.1]: State changed from crashed to starting
2019-12-01T12:09:44.201609+00:00 heroku[web.1]: Starting process with command `gunicorn BlogProject.wsgi`
2019-12-01T12:09:46.354564+00:00 heroku[web.1]: State changed from starting to crashed
2019-12-01T12:09:46.197581+00:00 app[web.1]: [2019-12-01 12:09:46 +0000] [4] [INFO] Starting gunicorn 20.0.4
2019-12-01T12:09:46.198162+00:00 app[web.1]: [2019-12-01 12:09:46 +0000] [4] [INFO] Listening at: http://0.0.0.0:21049 (4)
2019-12-01T12:09:46.198319+00:00 app[web.1]: [2019-12-01 12:09:46 +0000] [4] [INFO] Using worker: sync
2019-12-01T12:09:46.202320+00:00 app[web.1]: [2019-12-01 12:09:46 +0000] [10] [INFO] Booting worker with pid: 10
2019-12-01T12:09:46.207718+00:00 app[web.1]: [2019-12-01 12:09:46 +0000] [10] [ERROR] Exception in worker process
2019-12-01T12:09:46.207721+00:00 app[web.1]: Traceback (most recent call last):
2019-12-01T12:09:46.207724+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
2019-12-01T12:09:46.207726+00:00 app[web.1]: worker.init_process()
2019-12-01T12:09:46.207728+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 119, in init_process
2019-12-01T12:09:46.207730+00:00 app[web.1]: self.load_wsgi()
2019-12-01T12:09:46.207732+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 144, in load_wsgi
2019-12-01T12:09:46.207734+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2019-12-01T12:09:46.207745+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
2019-12-01T12:09:46.207747+00:00 app[web.1]: self.callable = self.load()
2019-12-01T12:09:46.207749+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 49, in load
2019-12-01T12:09:46.207751+00:00 app[web.1]: return self.load_wsgiapp()
2019-12-01T12:09:46.207753+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp
2019-12-01T12:09:46.207755+00:00 app[web.1]: return util.import_app(self.app_uri)
2019-12-01T12:09:46.207757+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/util.py", line 358, in import_app
2019-12-01T12:09:46.207759+00:00 app[web.1]: mod = importlib.import_module(module)
2019-12-01T12:09:46.207761+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/importlib/__init__.py", line 126, in import_module
2019-12-01T12:09:46.207763+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2019-12-01T12:09:46.207765+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 994, in _gcd_import
2019-12-01T12:09:46.207767+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 971, in _find_and_load
2019-12-01T12:09:46.207769+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 941, in _find_and_load_unlocked
2019-12-01T12:09:46.207771+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
2019-12-01T12:09:46.207773+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 994, in _gcd_import
2019-12-01T12:09:46.207775+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 971, in _find_and_load
2019-12-01T12:09:46.207777+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
2019-12-01T12:09:46.207778+00:00 app[web.1]: ModuleNotFoundError: No module named 'BlogProject'
2019-12-01T12:09:46.207849+00:00 app[web.1]: [2019-12-01 12:09:46 +0000] [10] [INFO] Worker exiting (pid: 10)
2019-12-01T12:09:46.241138+00:00 app[web.1]: [2019-12-01 12:09:46 +0000] [4] [INFO] Shutting down: Master
2019-12-01T12:09:46.242391+00:00 app[web.1]: [2019-12-01 12:09:46 +0000] [4] [INFO] Reason: Worker failed to boot.
2019-12-01T12:09:46.333585+00:00 heroku[web.1]: Process exited with status 3
2019-12-01T12:14:12.943946+00:00 app[api]: Starting process with command `bash` by user dfskeb@gmail.com
2019-12-01T12:14:18.026428+00:00 heroku[run.5828]: State changed from starting to up
2019-12-01T12:14:18.153662+00:00 heroku[run.5828]: Awaiting client
2019-12-01T12:14:18.184219+00:00 heroku[run.5828]: Starting process with command `bash`
2019-12-01T12:16:24.383977+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=theblogformamad.herokuapp.com request_id=eab55fd9-75e8-493a-8daa-3434d463f0f7 fwd="23.111.188.5" dyno= connect= service= status=503 bytes= protocol=http
2019-12-01T12:16:25.249745+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=theblogformamad.herokuapp.com request_id=4c6cb4e5-e736-41a0-8e15-13e48a57e31b fwd="23.111.188.5" dyno= connect= service= status=503 bytes= protocol=http
2019-12-01T12:27:22.392998+00:00 heroku[run.5828]: State changed from up to complete
2019-12-01T12:27:22.374816+00:00 heroku[run.5828]: Process exited with status 0

我已经尽力但不能解决

答案

我在您的日志的前几行中看到错误...

ModuleNotFoundError:没有名为“ BlogProject”的模块

当您在计算机上本地使用应用程序时,该应用程序是否正常工作?我们正在为此使用PyCharm。

请观看来自Corey Schafer(https://youtu.be/6DI_7Zja8Zc)的视频。它正在工作。

以上是关于当我将django应用程序部署到heroku时,该站点停止工作的主要内容,如果未能解决你的问题,请参考以下文章

使用docker将django应用程序部署到heroku时在哪里运行collectstatic?

Django/Celery 和 CloudAMQP/Heroku 的连接错误

当我当时在 Heroku 中部署 django 应用程序时,出现“Compiled Slug Size is too Large”错误

将网络测功机添加到 Heroku django 应用程序时如何克服“无法找到该编队”错误?

Pandas数据框一旦部署到heroku(Django项目)后就无法按预期方式运行

由于 PyWin32,无法将 Django 应用程序部署到 Heroku