【问题标题】:Heroku App crashes immediately with R10 and H10 errorsHeroku 应用程序立即崩溃并出现 R10 和 H10 错误
【发布时间】:2014-03-26 23:34:12
【问题描述】:

我的应用程序使用 foreman run 在本地运行良好,当我使用 python runserver.py 执行我的 runserver.py 文件时。当我把它推到 Heroku 时,它就崩溃了。我什至对我的 procfile 进行了更改:web: python runserver.py ${PORT} 以便 Heroku 将绑定到端口号,但无济于事......我已经解决这个问题将近 3 天了。首先是我的Procfile,现在是 Heroku……任何帮助都将不胜感激。此外,我在这个项目中使用 Python 和 Flask 框架——我遇到了 Heroku,但它似乎只适用于 RoR 应用程序..

2014-02-24T02:24:50.146153+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
    2014-02-24T02:24:51.323561+00:00 heroku[web.1]: Process exited with status 137
    2014-02-24T02:24:51.333621+00:00 heroku[web.1]: State changed from starting to crashed
    2014-02-24T02:24:51.334368+00:00 heroku[web.1]: State changed from crashed to starting
    2014-02-24T02:24:55.793531+00:00 heroku[web.1]: Starting process with command `python runserver.py`
    2014-02-24T02:24:57.117683+00:00 app[web.1]:  * Running on http://127.0.0.1:5000/
    2014-02-24T02:24:57.117683+00:00 app[web.1]:  * Restarting with reloader
    2014-02-24T02:23:43.987388+00:00 heroku[api]: Deploy c55f7b6 by shaunktw@gmail.com
    2014-02-24T02:23:43.987478+00:00 heroku[api]: Release v8 created by shaunktw@gmail.com
    2014-02-24T02:25:56.204701+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
    2014-02-24T02:25:56.204929+00:00 heroku[web.1]: Stopping process with SIGKILL
    2014-02-24T02:25:57.495657+00:00 heroku[web.1]: Process exited with status 137

过程文件:

web: python runserver.py ${PORT}

运行服务器.py:

from intro_to_flask import app

app.run(debug=True)

【问题讨论】:

  • 您似乎分享了您的 Procfile 而不是 runserver.py
  • @dirn 好吧,我的错,刚刚编辑过。

标签: python heroku flask


【解决方案1】:

我找到了这个问题的答案......基本上我必须绑定一个端口并指定我正在使用的主机:

在我的 runserver.py 文件中,我使用以下方法对其进行了修改:

import os
from intro_to_flask import app

port = int(os.environ.get("PORT", 5000))
app.run(debug=True, host='0.0.0.0', port=port)

这可能不是最优雅的方式。但它确实有效。

【讨论】:

    【解决方案2】:

    您需要指定$PORT 而不是${PORT} like

    web: python runserver.py $PORT
    

    【讨论】:

    • 我进行了更改,但我的应用仍然因相同的错误而崩溃。不知道为什么加载需要超过 60 秒。
    • 在 Heroku 的网站上,他们talk about using gunicorn。这对你来说是一个选择吗?我对 Python 了解不多。
    【解决方案3】:

    link 给出了一个使用 Heroku 启动 Flask 应用程序的简单示例

    【讨论】:

      猜你喜欢
      • 2013-09-11
      • 2016-08-20
      • 2012-06-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多