【问题标题】:Deploying Flask app on Heroku - web1:crashed在 Heroku 上部署 Flask 应用程序 - web1:crashed
【发布时间】:2014-09-02 20:15:57
【问题描述】:

我正在尝试将 Flask 应用程序部署到 Heroku,但收到此错误:

(venv)rgb:~/flaskapp/app$ heroku ps
=== web (1X): `gunicorn app:app`
web.1: crashed 2014/07/09 21:39:45 (~ 10s ago)

它在本地与“工头启动”一起工作,但在 Heroku 上推送它会导致网络崩溃:

(venv)rgb@rgb-K45VD:~/flaskapp/app$ foreman start 
21:41:01 web.1  | started with pid 3269

这是以下 heroku 日志: (venv)rgb@rgb-K45VD:~/flaskapp/app$ heroku 日志

2014-07-09T18:38:42.934053+00:00 heroku[api]: Enable Logplex by user
2014-07-09T18:38:42.934053+00:00 heroku[api]: Release v2 created by user
2014-07-09T18:38:57+00:00 heroku[slug-compiler]: Slug compilation started
2014-07-09T18:39:31+00:00 heroku[slug-compiler]: Slug compilation finished
2014-07-09T18:39:30.976889+00:00 heroku[api]: Scale to web=1 by user
2014-07-09T18:39:31.123082+00:00 heroku[api]: Deploy ea4c116 by user
2014-07-09T18:39:31.123204+00:00 heroku[api]: Release v3 created by user
2014-07-09T18:39:35.095809+00:00 heroku[web.1]: Starting process with command `gunicorn app:app`
2014-07-09T18:39:38.231874+00:00 heroku[web.1]: State changed from starting to crashed
2014-07-09T18:39:38.232507+00:00 heroku[web.1]: State changed from crashed to starting
2014-07-09T18:39:38.229063+00:00 heroku[web.1]: Process exited with status 3
2014-07-09T18:39:42.092210+00:00 heroku[web.1]: Starting process with command `gunicorn app:app`
2014-07-09T18:39:44.747854+00:00 heroku[web.1]: State changed from starting to up
2014-07-09T18:39:46.210641+00:00 heroku[web.1]: State changed from up to crashed
2014-07-09T18:39:46.180463+00:00 heroku[web.1]: Process exited with status 3
2014-07-09T18:39:50.025372+00:00 heroku[api]: Scale to web=1 by user
2014-07-09T18:41:30.849878+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=flazkeh.herokuapp.com request_id=89f286f6-44ec-4751-91ec-7411857fbd80 fwd="80.223.191.140" dyno= connect= service= status=503 bytes=
2014-07-09T18:41:31.434515+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=flazkeh.herokuapp.com request_id=63c33396-87d9-4b33-89a5-3f2288b707cd fwd="80.223.191.140" dyno= connect= service= status=503 bytes=

这似乎是错误:

2014-07-09T18:41:30.849878+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=flazkeh.herokuapp.com request_id=89f286f6-44ec-4751-91ec-7411857fbd80 fwd="80.223.191.140" dyno= connect= service= status=503 bytes=
2014-07-09T18:41:31.434515+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=flazkeh.herokuapp.com request_id=63c33396-87d9-4b33-89a5-3f2288b707cd fwd="80.223.191.140" dyno= connect= service= status=503 bytes=

任何帮助将不胜感激!

【问题讨论】:

    标签: python heroku flask


    【解决方案1】:

    确保您将 procfile 从 web: gunicorn app:app 更改为 web: gunicorn project:app。 此外,一旦您部署到 heroku,您将遇到数据库问题。最好的办法是“删除”数据库并创建一个新数据库或迁移。 使用命令 heroku logs 获取更多信息。

    【讨论】:

      【解决方案2】:

      从表面上看代码,我看不出有什么问题。您是否尝试在自己的机器上运行它?

      顺便说一句,代码中有一些东西导致它无法在我的机器上运行:

      • 需要有一个环境变量“APP_SETTINGS”(你设置了吗?)
      • 需要一个 models.py 模块 - 可能包含 BlogPost 类。 GitHub上好像没有这个文件?
      • 您安装了 flask-sqlalchemy 吗?

      【讨论】:

      • 请不要让我检查你的整个项目并为你调试它。你试图找出错误在哪里?
      • 顺便说一句:你的repo中多个文件存在合并冲突(会导致语法错误)
      猜你喜欢
      • 1970-01-01
      • 2020-09-07
      • 2012-11-22
      • 2019-04-06
      • 2023-03-27
      • 1970-01-01
      • 2022-06-30
      相关资源
      最近更新 更多