【问题标题】:Flask application deployed to Heroku returns Application Error部署到 Heroku 的 Flask 应用程序返回应用程序错误
【发布时间】:2014-09-15 08:24:11
【问题描述】:

我遇到了 heroku 无法成功运行我的应用程序的问题。我有 3 个关键文件:

  1. 带有核心引擎的 python 文件。
  2. 一个python文件,调用第一个python文件,运行Flask到render_templateindex.html,和
  3. 使用生成的数据的 index.html 文件 从核心引擎(通过第二个 python 文件)渲染 页面。

我在 requirements.txt 文件中记录了所有需要的依赖项,以及followed the "Deploying to Heroku" instructions on this boilerplate page

在执行git push heroku master 之后,我在 heroku 应用程序上遇到了应用程序错误。 这是 heroku 日志转储:

(venv)Bobs-MacBook-Pro:headline master$ heroku logs
2014-09-15T08:04:42.500102+00:00 heroku[api]: Enable Logplex by xxx@gmail.com
2014-09-15T08:04:42.500102+00:00 heroku[api]: Release v2 created by xxx@gmail.com
2014-09-15T08:10:32+00:00 heroku[slug-compiler]: Slug compilation started
2014-09-15T08:11:21+00:00 heroku[slug-compiler]: Slug compilation finished
2014-09-15T08:11:21.409088+00:00 heroku[api]: Deploy fa8d344 by xxx@gmail.com
2014-09-15T08:11:21.409184+00:00 heroku[api]: Release v3 created by xxx@gmail.com
2014-09-15T08:11:23.833224+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=headlyneme.herokuapp.com request_id=6ea6633a-4bfa-4cfa-9345-ac77f570e6a9 fwd="54.82.116.215" dyno= connect= service= status=503 bytes=
2014-09-15T08:11:55.722627+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=headlyneme.herokuapp.com request_id=ed7d46ba-cef2-4aef-bbe6-49e8244cb04c fwd="24.130.57.252" dyno= connect= service= status=503 bytes=
2014-09-15T08:11:56.045572+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=headlyneme.herokuapp.com request_id=08d43fc9-977a-4c89-86a3-267224fbb5a7 fwd="24.130.57.252" dyno= connect= service= status=503 bytes=

我做错了什么?我已经在我的 Mac 上使用 app.run(debug=True) 在本地运行它,没有任何问题,as seen here。我猜python文件运行的顺序有问题?

【问题讨论】:

  • 您如何在生产环境中运行您的应用程序?你的 Procfile 是什么样的?
  • Procfile 只有web: gunicorn hello:app --log-file=-。我正在尝试使用 heroku 在生产环境中运行应用程序 - 也许我不理解您的问题?
  • 您的存储库的根目录中有requirements.txt 文件吗?这就是 Heroku 知道您使用的是 Python,而不是 Ruby 或其他东西的方式。
  • 是的。我按照上面样板页面上的说明转储了所有 pip 依赖项。包括:Flask>=0.10.1 Jinja2>=2.7.3 PyRSS2Gen==1.0.0 Werkzeug==0.9.6 bdist-mpkg==0.4.4 beautifulsoup4==4.3.2 pyOpenSSL==0.13 python-dateutil==1.5 python-googlegeocoder>=0.2.0 requests==2.3.0 virtualenv==1.11.6 wsgiref==0.1.2 xattr==0.6.4

标签: python git heroku flask


【解决方案1】:

这通常发生在您在推送其他文件后添加 Procfile 时。因此,您的 heroku 应用程序不知道 Procfile 并且您没有运行任何测功机。

尝试运行heroku ps:scale web=1 以形成一个测功机,这有望让您的应用处理网络请求。我希望这会有所帮助!

【讨论】:

  • heroku ps:scale web=1 is Greaaaaaaat!
猜你喜欢
  • 1970-01-01
  • 2021-07-27
  • 2018-04-07
  • 2012-11-22
  • 1970-01-01
  • 2013-12-25
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多