Heroku部署错误:gunicorn.errors.HaltServer:<HaltServer'App加载失败。' 4>

时间:2020-06-07 16:55:48

标签: python flask heroku plotly-dash

我正在尝试部署使用plotly-dash框架构建的flask应用程序。但是,我遇到了gunicorn.errors.HaltServer。

app.py
index.py
- assets
- tabs
-- tab1
-- tab2

Procfile:

web: gunicorn index:app(也尝试过web: gunicorn index:serverapp:server

index.py包含以下用于运行应用程序的代码:

if __name__ == '__main__':
    app.run_server(debug=True)

app.py包括:

import dash
import flask
import dash_core_components as dcc
import dash_html_components as html
import dash_bootstrap_components as dbc


server = flask.Flask(__name__)
#app = dash.Dash(__name__, server=server)

app = dash.Dash(external_stylesheets=[dbc.themes.BOOTSTRAP])

app.config.suppress_callback_exceptions = True

要在本地部署,我运行python index.py可以正常工作。但是,我不太确定要将多选项卡应用程序部署到heroku。

跟踪:

2020-06-07T19:04:31.148521+00:00 heroku[web.1]: State changed from up to starting
2020-06-07T19:04:32.733304+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2020-06-07T19:04:32.782387+00:00 app[web.1]: [2020-06-07 19:04:32 +0000] [10] [INFO] Worker exiting (pid: 10)
2020-06-07T19:04:32.782606+00:00 app[web.1]: [2020-06-07 19:04:32 +0000] [4] [INFO] Handling signal: term
2020-06-07T19:04:32.783987+00:00 app[web.1]: [2020-06-07 19:04:32 +0000] [11] [INFO] Worker exiting (pid: 11)
2020-06-07T19:04:32.984167+00:00 app[web.1]: [2020-06-07 19:04:32 +0000] [4] [INFO] Shutting down: Master
2020-06-07T19:04:33.100057+00:00 heroku[web.1]: Process exited with status 0
2020-06-07T19:04:43.276350+00:00 heroku[web.1]: Starting process with command `gunicorn index:server`
2020-06-07T19:04:45.969485+00:00 app[web.1]: [2020-06-07 19:04:45 +0000] [4] [INFO] Starting gunicorn 19.9.0
2020-06-07T19:04:45.970465+00:00 app[web.1]: [2020-06-07 19:04:45 +0000] [4] [INFO] Listening at: http://0.0.0.0:36003 (4)
2020-06-07T19:04:45.970600+00:00 app[web.1]: [2020-06-07 19:04:45 +0000] [4] [INFO] Using worker: sync
2020-06-07T19:04:45.976630+00:00 app[web.1]: [2020-06-07 19:04:45 +0000] [10] [INFO] Booting worker with pid: 10
2020-06-07T19:04:46.025840+00:00 app[web.1]: [2020-06-07 19:04:46 +0000] [11] [INFO] Booting worker with pid: 11
2020-06-07T19:04:46.386303+00:00 heroku[web.1]: State changed from starting to up
2020-06-07T19:04:55.000000+00:00 app[api]: Build succeeded
2020-06-07T19:04:57.395895+00:00 app[web.1]: Failed to find application object 'server' in 'index'
2020-06-07T19:04:57.396485+00:00 app[web.1]: [2020-06-07 19:04:57 +0000] [11] [INFO] Worker exiting (pid: 11)
2020-06-07T19:04:57.443947+00:00 app[web.1]: Failed to find application object 'server' in 'index'
2020-06-07T19:04:57.445193+00:00 app[web.1]: [2020-06-07 19:04:57 +0000] [10] [INFO] Worker exiting (pid: 10)
2020-06-07T19:04:57.840352+00:00 app[web.1]: [2020-06-07 19:04:57 +0000] [4] [INFO] Shutting down: Master
2020-06-07T19:04:57.840598+00:00 app[web.1]: [2020-06-07 19:04:57 +0000] [4] [INFO] Reason: App failed to load.
2020-06-07T19:04:57.900650+00:00 heroku[web.1]: Process exited with status 4
2020-06-07T19:04:57.935000+00:00 heroku[web.1]: State changed from up to crashed
2020-06-07T19:04:57.937954+00:00 heroku[web.1]: State changed from crashed to starting
2020-06-07T19:05:08.770601+00:00 heroku[web.1]: Starting process with command `gunicorn index:server`
2020-06-07T19:05:10.916784+00:00 app[web.1]: [2020-06-07 19:05:10 +0000] [4] [INFO] Starting gunicorn 19.9.0
2020-06-07T19:05:10.917315+00:00 app[web.1]: [2020-06-07 19:05:10 +0000] [4] [INFO] Listening at: http://0.0.0.0:12394 (4)
2020-06-07T19:05:10.917416+00:00 app[web.1]: [2020-06-07 19:05:10 +0000] [4] [INFO] Using worker: sync
2020-06-07T19:05:10.921200+00:00 app[web.1]: [2020-06-07 19:05:10 +0000] [10] [INFO] Booting worker with pid: 10
2020-06-07T19:05:11.020805+00:00 app[web.1]: [2020-06-07 19:05:11 +0000] [18] [INFO] Booting worker with pid: 18
2020-06-07T19:05:11.572920+00:00 heroku[web.1]: State changed from starting to up
2020-06-07T19:05:20.160115+00:00 app[web.1]: Failed to find application object 'server' in 'index'
2020-06-07T19:05:20.160771+00:00 app[web.1]: [2020-06-07 19:05:20 +0000] [18] [INFO] Worker exiting (pid: 18)
2020-06-07T19:05:20.174812+00:00 app[web.1]: Failed to find application object 'server' in 'index'
2020-06-07T19:05:20.175384+00:00 app[web.1]: [2020-06-07 19:05:20 +0000] [10] [INFO] Worker exiting (pid: 10)
2020-06-07T19:05:20.510412+00:00 app[web.1]: [2020-06-07 19:05:20 +0000] [4] [INFO] Shutting down: Master
2020-06-07T19:05:20.510517+00:00 app[web.1]: [2020-06-07 19:05:20 +0000] [4] [INFO] Reason: App failed to load.
2020-06-07T19:05:20.563920+00:00 heroku[web.1]: Process exited with status 4
2020-06-07T19:05:20.592058+00:00 heroku[web.1]: State changed from up to crashed
2020-06-07T19:08:28.283874+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=stroom-cre-platform.herokuapp.com request_id=2f63ecb5-808b-4583-bb18-7d2ee6b31a5f fwd="103.90.69.217" dyno= connect= service= status=503 bytes= protocol=https

1 个答案:

答案 0 :(得分:2)

您必须将flask服务器传递给dash应用程序,即

server = flask.Flask(__name__)
app = dash.Dash(external_stylesheets=[dbc.themes.BOOTSTRAP], server=server)

假设此代码位于index.py中,则您的个人资料应该与

web: gunicorn index:server
相关问题