【问题标题】:django project with heroku: application error带有heroku的django项目:应用程序错误
【发布时间】:2018-12-13 23:10:34
【问题描述】:

我成功地将项目部署到 Heroku。但是当我运行 Heroku 打开它会引发应用程序错误 应用程序发生错误,无法提供您的页面。如果您是应用程序所有者,请查看您的日志以获取详细信息。

我的日志在这里

(dj12) λ heroku logs
2018-07-05T07:06:17.443987+00:00 app[api]: Initial release by user     ermiaskidanegebre@gmail.com
2018-07-05T07:06:17.443987+00:00 app[api]: Release v1 created by user ermiaskidanegebre@gmail.com
2018-07-05T07:06:17.909289+00:00 app[api]: Release v2 created by user ermiaskidanegebre@gmail.com
2018-07-05T07:06:17.909289+00:00 app[api]: Enable Logplex by user ermiaskidanegebre@gmail.com
2018-07-05T07:16:35.051508+00:00 app[api]: Attach DATABASE (@ref:postgresql-shaped-50056) by user ermiaskidanegebre@gmail.com
2018-07-05T07:16:35.051508+00:00 app[api]: Release v3 created by user ermiaskidanegebre@gmail.com
2018-07-05T07:24:48.143580+00:00 app[api]: Set SECRET_KEY config vars by user ermiaskidanegebre@gmail.com
2018-07-05T07:24:48.143580+00:00 app[api]: Release v4 created by user ermiaskidanegebre@gmail.com
2018-07-05T07:33:04.050618+00:00 app[api]: Set SECRET_KEY config vars by user ermiaskidanegebre@gmail.com
2018-07-05T07:33:04.050618+00:00 app[api]: Release v5 created by user ermiaskidanegebre@gmail.com
2018-07-05T07:40:34.881810+00:00 app[api]: Set EMAIL_PASSWORD config vars by user ermiaskidanegebre@gmail.com
2018-07-05T07:40:34.881810+00:00 app[api]: Release v6 created by user ermiaskidanegebre@gmail.com
2018-07-05T07:49:13.302208+00:00 app[api]: Release v7 created by user ermiaskidanegebre@gmail.com
2018-07-05T07:49:13.302208+00:00 app[api]: Set DISABLE_COLLECTSTATIC config vars by user ermiaskidanegebre@gmail.com
2018-07-05T07:54:43.000000+00:00 app[api]: Build started by user ermiaskidanegebre@gmail.com
2018-07-05T07:55:09.406852+00:00 app[api]: Release v8 created by user ermiaskidanegebre@gmail.com
2018-07-05T07:55:09.406852+00:00 app[api]: Deploy 2fdb68de by user ermiaskidanegebre@gmail.com
2018-07-05T07:55:18.000000+00:00 app[api]: Build succeeded
2018-07-05T07:57:14.239360+00:00 app[api]: Starting process with command `python manage.py migrate` by user ermiaskidanegebre@gmail.com
2018-07-05T07:57:20.853528+00:00 heroku[run.2986]: State changed from starting to up
2018-07-05T07:57:20.965558+00:00 heroku[run.2986]: Awaiting client
2018-07-05T07:57:21.013142+00:00 heroku[run.2986]: Starting process with command `python manage.py migrate`
2018-07-05T07:57:26.012552+00:00 heroku[run.2986]: Process exited with status 1
2018-07-05T07:57:26.032134+00:00 heroku[run.2986]: State changed from up to complete
2018-07-05T08:01:58.000000+00:00 app[api]: Build started by user ermiaskidanegebre@gmail.com
2018-07-05T08:02:15.941485+00:00 app[api]: Release v9 created by user ermiaskidanegebre@gmail.com
2018-07-05T08:02:15.941485+00:00 app[api]: Deploy 8a0e03de by user ermiaskidanegebre@gmail.com
2018-07-05T08:02:25.000000+00:00 app[api]: Build succeeded
2018-07-05T08:03:43.462294+00:00 heroku[run.1120]: Awaiting client
2018-07-05T08:03:43.510884+00:00 heroku[run.1120]: Starting process with command `python manage.py migrate`
2018-07-05T08:03:43.859691+00:00 heroku[run.1120]: State changed from starting to up
 2018-07-05T08:03:37.888541+00:00 app[api]: Starting process with command `python manage.py migrate` by user ermiaskidanegebre@gmail.com
2018-07-05T08:03:53.506152+00:00 heroku[run.1120]: Process exited with status 0
2018-07-05T08:03:53.525335+00:00 heroku[run.1120]: State changed from up to complete
2018-07-05T08:13:52.212453+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=django-ecommerce-2.herokuapp.com request_id=750bffb9-e6bb-4ea7-94bd-09772529bf3c fwd="82.26.20.87" dyno= connect= service= status=503 bytes= protocol=https
2018-07-05T08:13:52.636447+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=django-ecommerce-2.herokuapp.com request_id=be57a379-0d82-4251-9218-049d3cdfb9a6 fwd="82.26.20.87" dyno= connect= service= status=503 bytes= protocol=https
2018-07-05T08:57:48.239032+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=django-ecommerce-2.herokuapp.com request_id=e5708b4e-1ef6-4167-a70a-0a99c9b8aecf fwd="82.26.20.87" dyno= connect= service= status=503 bytes= protocol=https
 2018-07-05T08:57:48.702316+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=django-ecommerce-2.herokuapp.com request_id=d92730e4-c5e9-4570-a709-311a07e0e3dc fwd="82.26.20.87" dyno= connect= service= status=503 bytes= protocol=https
2018-07-05T09:11:36.000000+00:00 app[api]: Build started by user ermiaskidanegebre@gmail.com
2018-07-05T09:11:53.696459+00:00 app[api]: Deploy 2993315c by user ermiaskidanegebre@gmail.com
 2018-07-05T09:11:53.696459+00:00 app[api]: Release v10 created by user ermiaskidanegebre@gmail.com
2018-07-05T09:12:03.000000+00:00 app[api]: Build succeeded
2018-07-05T09:32:26.285646+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=django-ecommerce-2.herokuapp.com request_id=08b476e4-c7f9-43b4-b706-9d44d3b8c8c1 fwd="82.26.20.87" dyno= connect= service= status=503 bytes= protocol=https
2018-07-05T09:32:55.648599+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=django-ecommerce-2.herokuapp.com request_id=5e4b151f-757b-49ad-8138-c47877c2c3e1 fwd="82.26.20.87" dyno= connect= service= status=503 bytes= protocol=https
2018-07-05T11:09:37.172582+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=django-ecommerce-2.herokuapp.com request_id=ea6c2402-cfe2-4cb5-a910-2b6d152174f4 fwd="82.26.20.87" dyno= connect= service= status=503 bytes= protocol=https
2018-07-05T11:10:05.085667+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=django-ecommerce-2.herokuapp.com request_id=f91cef75-167c-4160-8709-e73736384dbc fwd="82.26.20.87" dyno= connect= service= status=503 bytes= protocol=https
2018-07-05T11:10:06.448716+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=django-ecommerce-2.herokuapp.com request_id=5fa29e24-e3d1-439f-bf88-dd1f266ac85a fwd="82.26.20.87" dyno= connect= service= status=503 bytes= protocol=https
 2018-07-05T11:22:38.501221+00:00 app[api]: Starting process with command `bash` by user ermiaskidanegebre@gmail.com
 2018-07-05T11:22:43.651327+00:00 heroku[run.8345]: Awaiting client
 2018-07-05T11:22:43.684186+00:00 heroku[run.8345]: Starting process with command `bash`
 2018-07-05T11:22:43.729572+00:00 heroku[run.8345]: State changed from starting to up
 2018-07-05T11:29:31.865357+00:00 heroku[run.8345]: Process exited with status 127
 2018-07-05T11:29:32.006562+00:00 heroku[run.8345]: State changed from up to     complete

我的过程文件

"web: gunicorn ecommerce2.wsgi" 

我的 wsgi.py

import os

from django.core.wsgi import get_wsgi_application

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

application = get_wsgi_application()

从文档中与 H14 相关的错误可以通过 heroku ps:scale web=1 修复,然后弹出

Scaling dynos... !
!    Couldn't find that process type.

当我检查我的 Heroku 帐户时,资源中的 Dynos 说的是下面的 tex,即使我成功添加了我的 Procfile。

This app has no process types yet 
Add a Procfile to your app in order to define its process types. Learn more

我该如何解决这个问题? 谢谢你的帮助。

【问题讨论】:

  • 您的文件是“procfile”还是“Procfile”?它的内容真的被引号包围了吗?
  • 它是 Procfile 并且被引号包围
  • 然后把引号去掉。
  • 感谢 Daniel 成功了。

标签: django heroku web-deployment


【解决方案1】:

今天我遇到了同样的错误。在我的根目录中,我的 Procfile 没有任何扩展名,但是当我在 Visual Studio 代码中打开代码时,Procfile 具有扩展名 .txt 并以“Procfile.txt”的形式出现。我刚刚从文件中删除了 .txt 并保存了它。这解决了我的错误。

您可以参考我的帖子以获得更多说明:

Getting application error while running the python app on heroku

【讨论】:

  • 我没有更改 Procfile 中的任何内容,我保持它与我的帖子中提到的“web: gunicorn script1:app”相同。我被这个问题困扰了好几个小时。
  • 如果您能够成功将更改推送到 git 但仍然无法打开应用程序。 1. 检查 Procfile 是否保存为文件而不是笔记本。 2. 您的 requirements.txt 包含您在 scipts 中使用的所有库。 3. 您的 runtime.txt 包含您在系统上使用的 python 版本。
【解决方案2】:

您的应用没有任何进程正在运行。

您需要使用heroku ps:scale web=1 命令扩展您的web dyno。

当然,这假设您在Procfile 中配置了web 进程类型。

【讨论】:

  • Damien,我在命令中执行 Heroku ps:sacle web=1,它会抛出“Scaling dynos ... !! 找不到该进程类型。”
  • 这意味着你没有在你的 Procfile 中设置任何web dyno。
  • 我使用 heroku ps:scale web=1 来设置网络测功机,还是有其他方法可以设置测功机?
【解决方案3】:

上次我遇到此问题时,它与未找到要求有关。从本地更新您的 requirements.txt 文件。

你想要做的也在你的settings.py中

DEBUG = False
DEBUG_PROPAGATE_EXCEPTIONS = True

添加这些生产线。这将传播错误记录。在那里你可以看到为什么你会收到应用程序错误。

(我愿意打赌它缺少一些包裹。让我知道它是什么。)

【讨论】:

  • Ojas Kale,好吧,但错误仍然是一样的。如果我错过了 requirements.txt 的步骤,我使用 pip freeze > requirements.txt 和 debug_propagate 我 git 添加修改后的文件,然后提交,然后推送到 Heroku。
  • 尝试将这些行添加到 settings.py 并查看 heroku 中的日志。
猜你喜欢
  • 1970-01-01
  • 2020-09-12
  • 1970-01-01
  • 1970-01-01
  • 2023-03-24
  • 2017-07-08
  • 1970-01-01
  • 2017-09-04
  • 2020-08-08
相关资源
最近更新 更多