【问题标题】:Flask on Heroku: failed to find attribute <app_name> in run script: error H10 desc="App crashed"Heroku 上的 Flask:在运行脚本中找不到属性 <app_name>:错误 H10 desc="App crashed"
【发布时间】:2021-08-20 20:36:05
【问题描述】:

这是我的第一个(真正的)flask 应用程序,本质上是 Corey Schafer Flask YouTube 教程的扩展。

根文件夹:

Procfile:

web: gunicorn --bind 0.0.0.0:$PORT run:bsstg

run.py:

from bsstg import create_app

app = create_app()

if __name__ == '__main__':
    app.run(debug=False)

bsstg 文件夹:

完整的错误列表:

2021-08-21T14:57:45.224522+00:00 heroku[web.1]: State changed from starting to up
2021-08-21T14:57:47.689647+00:00 app[web.1]: /app/.heroku/python/lib/python3.9/site-packages/flask_sqlalchemy/__init__.py:872: FSADeprecationWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future.  Set it to True or False to suppress this warning.
2021-08-21T14:57:47.689676+00:00 app[web.1]: warnings.warn(FSADeprecationWarning(
2021-08-21T14:57:47.691540+00:00 app[web.1]: /app/.heroku/python/lib/python3.9/site-packages/flask_sqlalchemy/__init__.py:872: FSADeprecationWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future.  Set it to True or False to suppress this warning.
2021-08-21T14:57:47.691542+00:00 app[web.1]: warnings.warn(FSADeprecationWarning(
2021-08-21T14:57:48.011870+00:00 app[web.1]: Failed to find attribute 'bsstg' in 'run'.
2021-08-21T14:57:48.012140+00:00 app[web.1]: [2021-08-21 14:57:48 +0000] [8] [INFO] Worker exiting (pid: 8)
2021-08-21T14:57:48.012928+00:00 app[web.1]: Failed to find attribute 'bsstg' in 'run'.
2021-08-21T14:57:48.013176+00:00 app[web.1]: [2021-08-21 14:57:48 +0000] [7] [INFO] Worker exiting (pid: 7)
2021-08-21T14:57:48.130969+00:00 app[web.1]: [2021-08-21 14:57:48 +0000] [4] [INFO] Shutting down: Master
2021-08-21T14:57:48.131000+00:00 app[web.1]: [2021-08-21 14:57:48 +0000] [4] [INFO] Reason: App failed to load.
2021-08-21T14:57:48.194499+00:00 heroku[web.1]: Process exited with status 4
2021-08-21T14:57:48.281397+00:00 heroku[web.1]: State changed from up to crashed
2021-08-21T14:57:55.591575+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=bsstg.herokuapp.com request_id=3418126a-a6f6-4e31-93c9-0c688104f8e3 fwd="109.153.222.121" dyno= connect= service= status=503 bytes= protocol=https
2021-08-21T14:57:56.000370+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=bsstg.herokuapp.com request_id=c9360a07-edaa-4857-b5d6-4dcd445adbf7 fwd="109.153.222.121" dyno= connect= service= status=503 bytes= protocol=https

错误

在“运行”中找不到属性“bsstg””

(bsstg 是我的应用程序和它所在文件夹的名称)是我用作问题的标题,但也许这一直在引导我。现在两天了,任何指针都非常感谢。

【问题讨论】:

  • “我知道已经有类似的问题了;我想我已经尝试了所有提供的答案,但我总是以 H10 错误结束”,即研究工作......?源代码、目录结构、错误跟踪和对原始代码应用程序的引用是从 .... 即明确的问题开发的。需要为 bsstg bishops stortford 可持续发展过渡小组发布和开发网页......即有用。请撤消您对此问题的降级 - 谢谢

标签: python flask gunicorn


【解决方案1】:

您的Procfile 几乎肯定是错误的:

web: gunicorn --bind 0.0.0.0:$PORT run:bsstg

这会将Gunicorn 作为web 进程(接受传入的HTTP 和HTTPS 请求的进程)运行。独角兽expects a WSGI app as an argument。你传入了run:bsstg,它告诉Gunicorn 运行bsstgrun 模块中的任何内容。

这会导致您看到的错误:

Failed to find attribute 'bsstg' in 'run'

run.py 中没有bsstg; WSGI 应用程序名为 app。尝试将其更改为

web: gunicorn --bind 0.0.0.0:$PORT run:app

然后提交并重新部署。

【讨论】:

    猜你喜欢
    • 2020-04-28
    • 2021-10-22
    • 1970-01-01
    • 2018-04-09
    • 1970-01-01
    • 1970-01-01
    • 2016-07-21
    • 2020-12-13
    • 2015-03-01
    相关资源
    最近更新 更多