Heroku应用程序错误-code = H10 desc =“应用程序崩溃”

我正在尝试在heroku上部署破折号应用程序。

一切正常(在本地也可以),除非运行heroku open时出现此应用程序错误:

Heroku应用程序错误-code = H10 desc =“应用程序崩溃”

heroku logs --tail然后给出:

2019-11-22T22:55:41.598239+00:00 heroku[web.1]: State changed from up to crashed
2019-11-22T22:55:41.587218+00:00 heroku[web.1]: Process exited with status 3
2019-11-22T22:55:42.000000+00:00 app[api]: Build succeeded
2019-11-22T22:55:59.485489+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=romania2019.herokuapp.com request_id=d48fde4a-bd7e-47e2-9a21-bdf589ef281a fwd="152.115.83.242" dyno= connect= service= status=503 bytes= protocol=https
2019-11-22T22:55:59.851491+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=romania2019.herokuapp.com request_id=b6bbb5e8-8667-42f2-b083-b7bf26b5ae14 fwd="152.115.83.242" dyno= connect= service= status=503 bytes= protocol=https

有什么建议我下一步应该去看吗?


这是我要部署的app.py

import datetime
import time

import dash
import dash_core_components as dcc
import dash_html_components as html
import plotly
from dash.dependencies import Input,Output

import numpy as np
from selenium import webdriver

url = 'https://prezenta.bec.ro/prezidentiale24112019/abroad-precincts'


profile = webdriver.FirefoxProfile()
profile.set_preference("browser.preferences.instantApply",True)
profile.set_preference("browser.helperApps.neverAsk.saveToDisk","text/plain,application/octet-stream,application/binary,text/csv,application/csv,application/excel,text/comma-separated-values,text/xml,application/xml")
profile.set_preference("browser.helperApps.alwaysAsk.force",False)
profile.set_preference("browser.download.manager.showWhenStarting",False)
profile.set_preference("browser.download.folderList",1)


options = webdriver.FirefoxOptions()
options.headless = True

# create a new Firefox session
driver = webdriver.Firefox(firefox_profile=profile,options=options)
driver.implicitly_wait(30)
driver.get(url)

# Find button and click on it
ELEMENT = driver.find_element_by_xpath('//*[@id="root"]/main/section/div[1]/div[1]/div[5]/div/div[2]/div/h2')

def update(ELEMENT):
    # time.sleep(2.9)
    return int(ELEMENT.text.replace('.',''))


external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']

app = dash.Dash(__name__,external_stylesheets=external_stylesheets)

server = app.server

app.layout = html.Div(
    html.Div([
        html.H4('ROMANIA - Presidential Elections Live Feed'),html.Div(id='live-update-text'),dcc.Graph(id='live-update-graph'),dcc.Interval(
            id='interval-component',interval=60*1000,# in milliseconds
            n_intervals=0
        )
    ])
)

time.sleep(5)
@app.callback(Output('live-update-text','children'),[Input('interval-component','n_intervals')])
def update_metrics(n):
    no = update(ELEMENT)
    style = {'padding': '5px','fontSize': '16px'}
    return [
        html.Span('Voters: {}'.format(no),style=style),html.Span('Voters/Min: {}'.format(np.diff(data['number'])[-5:].mean()),style=style)
    ]


data = {'time': [],'number': []}

# Multiple components can update everytime interval gets fired.
@app.callback(Output('live-update-graph','figure'),'n_intervals')])
def update_graph_live(n):
    # Collect some data
    data['time'].append(datetime.datetime.now()) # + datetime.timedelta(seconds=3))

    try:
        no = update(ELEMENT)
        data['number'].append(no)
    except:
        data['number'].append(no)



    # Create the graph with subplots
    fig = plotly.subplots.make_subplots(rows=2,cols=1,vertical_spacing=0.1)
    fig['layout']['margin'] = {
        'l': 30,'r': 10,'b': 30,'t': 10
    }
    fig['layout']['legend'] = {'x': 0,'y': 1,'xanchor': 'left'}

    fig.append_trace({
        'x': data['time'],'y': data['number'],'name': 'Voters','type': 'scatter'
    },1,1)
    fig.append_trace({
        'x': data['time'],'y': np.diff(data['number']),'text': data['time'],'name': 'Voters / Min',2,1)
    fig.layout.update(height=800,)

    return fig


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

它基本上读取投票者的数量并显示每分钟的投票数量。

这里提供了我一直遵循的部署说明:https://dash.plot.ly/deployment

wuchun198799 回答:Heroku应用程序错误-code = H10 desc =“应用程序崩溃”

打开你的 git bash 并发布 log --tails 它将显示您的错误类型 H10 是由于缺少依赖项的某些错误或您的 procfiles 未正确设置而导致应用程序崩溃,因此请尝试阅读错误类型并查看您的代码。如果您的应用在本地主机上运行良好,请尝试 网页:gunicorn 索引:服务器 --preload --timeout60。

本文链接:https://www.f2er.com/3047738.html

大家都在问