错误代码=H14 desc=“没有正在运行的Web进程”-heroku部署

问题描述 投票:0回答:1

嗨,我是heroku新手,我正在尝试从github部署一个plotly-dash应用程序。虽然应用程序部署没有错误,但当我单击 URL 时,我收到以下错误消息:

Application error
An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details. You can do this from the Heroku CLI with the command

heroku 日志输出:

2024-01-03T11:13:34.000Z casino-5f heroku/router at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=casino-5f-958d8779bafe.herokuapp.com request_id=9ab8e8a8-7d7d-4059-a5a3-1b9735cee671 fwd="2.86.68.160" dyno= connect= service= status=503 bytes= protocol=https

我的文件结构是:

.venv
MyCSVApp
-->src
   -->__init__.py
   -->app.py
   -->Procfile
   -->data
      -->data.csv
requirements.txt
runtime.txt

我的Procfile中的代码是:

web: gunicorn app:server

我的破折号应用程序是:

# Dash Board
app = dash.Dash(__name__)
app.config.suppress_callback_exceptions = True

# Declare server for Heroku deployment. Needed for Procfile.
server = app.server

# Define the layout of the dashboard
app.layout = html.Div([
    dcc.Tabs(id="tabs", value='personal', children=[
        dcc.Tab(label='Player Data', value='personal'),
        dcc.Tab(label='Table Data', value='global'),
    ]),
    html.Div(id='page-content'),
])

# Callback to switch between subpages
@app.callback(Output('page-content', 'children'), Input('tabs', 'value'))
def render_content(tab):
    if tab == 'personal':
        return html.Div([
            dcc.Dropdown(
                id='Player',
                options=[{'label': person, 'value': person} for person in namelist],
                value=namelist[1]  # Set the default value
            ),
            html.Div(id='current-profit'),
            html.Div(id='session-progress'),       
            html.Div(id='monthly-progress'),  # Container for the monthly personal data
            html.Div(id='gauge-chart'),  # Container for the gauge charts
        ])
    elif tab == 'global':
        return html.Div([
            dcc.Dropdown(
                id='row-dropdown',
                options=[{'label': '{1} - Session {0}'.format(i+1, pd.to_datetime(dftime2.index.values[i]).strftime('%d-%b')), 'value': i} for i in range(dftime2.shape[0])],
                value=dftime2.shape[0]-2,  # Default to the last game
                style={'width': '50%'}
            ),
            html.Div(id='results-table-container', style={'margin-bottom': '50px'}),  # Change id to 'results-table-container'
            dcc.Checklist(
                id='Name-Checklist',
                options=[{'label': person, 'value': person} for person in namelist],
                value=namelist[:5],  # Select the first 5 people from the namelist
                labelStyle={'font-size': '24px',},  # Increase font size and center labels
                inline=True,
            ),
            html.Div(id='bar-plot'),
            html.Div(id='time-lapse'),
        ])
###
relevant callbacks
###
if __name__ == '__main__':
    app.run_server(debug=False)
    #app.run_server(port=8050, threaded=False)

该应用程序在本地运行。您知道是什么导致我收到错误消息吗?

python github heroku deployment plotly-dash
1个回答
-1
投票

错误消息“没有正在运行的 Web 进程”通常表示 Heroku 部署存在问题,并且表明没有可用于处理传入 Web 请求的进程。

您可以检查以下几项:

  1. Proc文件配置: 确保您的

    Procfile
    配置正确。就你而言,这似乎是正确的:

    web: gunicorn app:server
    

    这告诉 Heroku 使用

    gunicorn
    入口点运行
    app:server
    服务器。

  2. Gunicorn 安装: 确保

    gunicorn
    在您的
    requirements.txt
    文件中列出。如果不存在,请添加并重新部署:

    gunicorn==20.1.0
    

    更新

    requirements.txt
    后,再次部署您的应用程序。

  3. 检查 Heroku 日志: Heroku 日志可以提供有关问题所在的更多详细信息。您可以使用 Heroku CLI 查看日志:

    heroku logs --tail
    

    查找可能表明问题原因的任何错误消息或堆栈跟踪。

  4. 扩展 Web 流程: 确保您已在 Heroku 上扩展了 Web 流程。您可以使用以下命令来执行此操作:

    heroku ps:scale web=1
    

    此命令可确保至少有一个 Web 进程正在运行。

  5. 检查您的 Heroku 仪表板: 转到 Heroku 仪表板,导航到您的应用程序,然后检查“概述”选项卡。确保其中没有提到任何警告或问题。

  6. 动力阵型: 验证您的 Heroku 应用程序是否至少有一个正在运行的 Web dyno。您可以在 Heroku 仪表板的“资源”选项卡下进行检查。

  7. 确保端口是动态设置的: 修改您的

    app.run_server
    行以使用
    process.env.PORT
    作为端口:

    if __name__ == '__main__':
        app.run_server(debug=False, port=int(os.environ.get('PORT', 8050)))
    

    确保在脚本顶部导入

    os

进行这些检查和调整后,将您的应用程序重新部署到 Heroku 并查看问题是否仍然存在。如果仍然存在问题,Heroku 日志应该提供有关问题所在的更具体信息。

© www.soinside.com 2019 - 2024. All rights reserved.