python - 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 文件夹:
完整的错误列表:
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 是我的应用程序和它所在文件夹的名称)是我用作问题的标题,但也许这一直在引导我。现在两天了,所以任何指针都非常感谢。
解决方案
你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
然后提交并重新部署。
推荐阅读
- docker - 带有 BUILDKIT_INLINE_CACHE 的 docker --cache-from 不能每秒钟运行一次
- javascript - lodash 过多的递归
- powershell - 可以从一个 Power Shell 窗口运行 yarn 命令,但不能从另一个窗口运行。什么可以解释这种差异?
- r - 在西班牙计算机上将 .csv 文件读入 R 时忽略逗号分隔符
- javascript - 期望一个赋值或函数调用,而是看到一个表达式 no-unused-expressions - 如何修复这个 CI 错误?
- node.js - Actions-on-google 图书馆列表和轮播不起作用
- multithreading - 具有多线程的芹菜工人 - 如何同时更新结果
- c# - 使用 c# 更改 FontAwesome 文本和 fontfamily - xamarin.forms
- java - Java - TextFlow 如何添加字符串列表?一个接一个?
- python - 对诽谤内容进行分类