【问题标题】:Python Heroku shows R10 (Boot timeout) ErrorPython Heroku 显示 R10(启动超时)错误
【发布时间】:2021-11-29 17:05:14
【问题描述】:

我正在尝试在 Heroku 中托管一个 Flask 应用程序,但我遇到了启动超时错误 (R10)。
其他答案告诉我在运行中使用 host="0.0.0.0" ,但它仍然无法正常工作。
我正在使用 Heroku CLI、Windows (CMD)、Python 3.7.7。

错误

2021-10-10T18:05:14.522910+00:00 heroku[web.1]: Starting process with command `waitress-serve app:app`
2021-10-10T18:05:15.701238+00:00 app[web.1]: INFO:waitress:Serving on http://0.0.0.0:8080
2021-10-10T18:06:14.938492+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2021-10-10T18:06:15.273888+00:00 heroku[web.1]: Stopping process with SIGKILL
2021-10-10T18:06:15.448673+00:00 heroku[web.1]: Process exited with status 137
2021-10-10T18:06:15.535916+00:00 heroku[web.1]: State changed from starting to crashed
2021-10-10T18:06:15.574210+00:00 heroku[web.1]: State changed from crashed to starting
2021-10-10T18:06:18.322384+00:00 heroku[web.1]: Starting process with command `waitress-serve app:app`
2021-10-10T18:06:19.508990+00:00 app[web.1]: INFO:waitress:Serving on http://0.0.0.0:8080
2021-10-10T18:06:35.678582+00:00 heroku[router]: at=error code=H20 desc="App boot timeout" method=GET path="/favicon.ico" host=mhd-project.herokuapp.com request_id=5e553adf-0b86-4663-896f-cc948cac3e62 fwd="79.252.124.156" dyno= connect= service= status=503 bytes= protocol=https
2021-10-10T18:07:03.746794+00:00 heroku[router]: at=error code=H20 desc="App boot timeout" method=GET path="/" host=mhd-project.herokuapp.com request_id=67e98e81-aedf-484c-af6f-61500d797daa fwd="79.252.124.156" dyno= connect= service= status=503 bytes= protocol=https
2021-10-10T18:07:06.871218+00:00 heroku[router]: at=error code=H20 desc="App boot timeout" method=GET path="/" host=mhd-project.herokuapp.com request_id=5c7c269b-1261-4c99-b952-f559314f2460 fwd="79.252.124.156" dyno= connect= service= status=503 bytes= protocol=https
2021-10-10T18:07:19.041046+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2021-10-10T18:07:19.174484+00:00 heroku[web.1]: Stopping process with SIGKILL
2021-10-10T18:07:19.346300+00:00 heroku[web.1]: Process exited with status 137
2021-10-10T18:07:19.393363+00:00 heroku[web.1]: State changed from starting to crashed
2021-10-10T18:07:49.835669+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=mhd-project.herokuapp.com request_id=a05bccea-a6e9-4f85-b9d6-0c9667ca2e50 fwd="79.252.124.156" dyno= connect= service= status=503 bytes= protocol=https

应用程序.py

from flask import Flask, render_template, request, g, flash, redirect, jsonify
import sqlite3
from flask_login import LoginManager, login_user, UserMixin, current_user, logout_user
from datetime import datetime,timedelta, date

...

if __name__ == "__main__":
      app.run(host='0.0.0.0')

requirements.txt

click==7.1.2
Jinja2==2.11.2
itsdangerous==1.1.0
Werkzeug==1.0.1
Flask==1.1.2
SQLAlchemy==1.3.22
Flask-SQLAlchemy==2.4.4
waitress==2.0.0
Flask-Login==0.5.0

过程文件

web: waitress-serve app:app

【问题讨论】:

    标签: python python-3.x heroku


    【解决方案1】:

    过程文件

    web: bundle exec thin start -p $PORT
    

    这使用带有弹簧启动的 docker 容器为我修复了它

    得到了帮助:Heroku Boot Timeout (Error R10)

    【讨论】:

      【解决方案2】:

      您需要从 Heroku 获取端口配置,并在您的应用上使用它:

      if __name__ == "__main__":
          port = int(os.environ.get("PORT", 5000))
          app.run(host='0.0.0.0', port=port)
      

      参考:https://blog.heroku.com/python_and_django

      【讨论】:

      • 好的,谢谢。
      猜你喜欢
      • 2014-01-13
      • 2012-05-15
      • 2014-03-24
      • 1970-01-01
      • 2015-08-15
      • 2019-06-01
      • 1970-01-01
      • 2017-02-15
      • 2018-10-13
      相关资源
      最近更新 更多