,python,flask,gunicorn"/>

首页 > 解决方案 > Heroku上的烧瓶:找不到属性在运行脚本中:错误 H10 desc="App crashed"

问题描述

这是我的第一个(合适的)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 文件夹:

[![bsstg 文件夹内容][2]][2] [2]: https://i.stack.imgur.com/DXnw3.png

完整的错误列表:

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

标签: pythonflaskgunicorn

解决方案


Procfile几乎肯定是错的:

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

会将 Gunicorn作为一个web进程运行(接受传入的 HTTP 和 HTTPS 请求的进程)。Gunicorn期望 WSGI 应用程序作为参数。您正在传递run:bsstg,它告诉 Gunicorn 运行模块bsstg中的任何内容。run

这会导致您看到的错误:

Failed to find attribute 'bsstg' in 'run'

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

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

然后提交并重新部署。


推荐阅读