Heroku上托管的Python应用程序突然停止工作(错误代码H10)

2024-10-01 22:42:12 发布

您现在位置:Python中文网/ 问答频道 /正文

2020-02-21T04:40:16.085005+00:00 app[web.1]: [2020-02-21 04:40:16 +0000] [4] [INFO] Using worker: sync
2020-02-21T04:40:16.090866+00:00 app[web.1]: [2020-02-21 04:40:16 +0000] [14] [INFO] Booting worker with pid: 14
2020-02-21T04:40:16.169291+00:00 app[web.1]: [2020-02-21 04:40:16 +0000] [22] [INFO] Booting worker with pid: 22
2020-02-21T04:40:16.285550+00:00 app[web.1]: [2020-02-21 04:40:16 +0000] [30] [INFO] Booting worker with pid: 30
2020-02-21T04:40:16.885772+00:00 app[web.1]: /app/.heroku/vendor/lib/python2.7/site-packages/flask_sqlalchemy/__init__.py:835: 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.
2020-02-21T04:40:16.885794+00:00 app[web.1]: 'SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and '
2020-02-21T04:40:16.991873+00:00 app[web.1]: /app/.heroku/vendor/lib/python2.7/site-packages/flask_sqlalchemy/__init__.py:835: 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.
2020-02-21T04:40:16.991877+00:00 app[web.1]: 'SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and '
2020-02-21T04:40:17.098026+00:00 app[web.1]: /app/.heroku/vendor/lib/python2.7/site-packages/flask_sqlalchemy/__init__.py:835: 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.
2020-02-21T04:40:17.098028+00:00 app[web.1]: 'SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and '
2020-02-21T04:40:17.810758+00:00 heroku[router]: at=info method=GET path="/" host=overwatchperfectflex.herokuapp.com request_id=c9bde3ed-25fd-418c-a289-79185c729281 fwd="40.94.36.55" dyno=web.1 connect=1ms service=18ms status=200 bytes=3793 protocol=https
2020-02-21T04:40:18.001787+00:00 heroku[router]: at=info method=GET path="/static/index.js?h=1575409895" host=overwatchperfectflex.herokuapp.com request_id=3741ce43-7f21-4bca-9cba-c65e4b899de4 fwd="40.94.36.55" dyno=web.1 connect=0ms service=10ms status=200 bytes=4656 protocol=https
2020-02-21T04:40:17.950826+00:00 heroku[router]: at=info method=GET path="/static/style.css?h=1575409895" host=overwatchperfectflex.herokuapp.com request_id=b39fca0f-0c36-471b-8e9f-356052939856 fwd="40.94.36.55" dyno=web.1 connect=0ms service=9ms status=200 bytes=5526 protocol=https
2020-02-21T04:40:18.115039+00:00 heroku[router]: at=info method=GET path="/static/sample-screenshot.jpg?h=1575409895" host=overwatchperfectflex.herokuapp.com request_id=f2ebea0f-d94a-48b6-ab07-1e6176ea1803 fwd="40.94.36.55" dyno=web.1 connect=0ms service=12ms status=200 bytes=194538 protocol=https
2020-02-21T04:40:18.128110+00:00 heroku[router]: at=info method=GET path="/static/sample-cards-screen.jpg?h=1575409895" host=overwatchperfectflex.herokuapp.com request_id=f187f422-58fa-4c5c-bc8c-5a381b8fc0b6 fwd="40.94.36.89" dyno=web.1 connect=1ms service=14ms status=200 bytes=156857 protocol=https
2020-02-21T04:40:18.204377+00:00 heroku[router]: at=info method=GET path="/static/sample-screenshot2.jpg?h=1575409895" host=overwatchperfectflex.herokuapp.com request_id=a21db7e3-aa67-4b38-aec2-255e603592cf fwd="40.94.36.97" dyno=web.1 connect=1ms service=18ms status=200 bytes=362587 protocol=https
2020-02-21T04:40:18.257411+00:00 heroku[router]: at=info method=GET path="/" host=overwatchperfectflex.herokuapp.com request_id=a7420d52-8572-40d5-9234-2a12c90b3ab1 fwd="40.94.96.47" dyno=web.1 connect=0ms service=3ms status=200 bytes=3793 protocol=https
2020-02-21T04:40:18.554730+00:00 heroku[router]: at=info method=GET path="/static/index.js?h=1575409895" host=overwatchperfectflex.herokuapp.com request_id=ff63c23b-ee06-4fc5-b2d1-a3bc2bb1bcb8 fwd="40.94.96.47" dyno=web.1 connect=0ms service=3ms status=200 bytes=4656 protocol=https
2020-02-21T04:40:18.441184+00:00 heroku[router]: at=info method=GET path="/static/style.css?h=1575409895" host=overwatchperfectflex.herokuapp.com request_id=31d0bdc2-3a4a-470f-b077-769452833050 fwd="40.94.96.47" dyno=web.1 connect=1ms service=3ms status=200 bytes=5526 protocol=https
2020-02-21T04:40:18.730303+00:00 heroku[router]: at=info method=GET path="/static/sample-cards-screen.jpg?h=1575409895" host=overwatchperfectflex.herokuapp.com request_id=15a50040-049a-4aeb-b61e-cc0f50fbc173 fwd="40.94.96.88" dyno=web.1 connect=1ms service=14ms status=200 bytes=156857 protocol=https
2020-02-21T04:40:18.722330+00:00 heroku[router]: at=info method=GET path="/static/sample-screenshot.jpg?h=1575409895" host=overwatchperfectflex.herokuapp.com request_id=b66d1329-4ddd-476c-b8c5-fbca4817ce18 fwd="40.94.96.47" dyno=web.1 connect=0ms service=14ms status=200 bytes=194538 protocol=https
2020-02-21T04:40:18.952974+00:00 heroku[router]: at=info method=GET path="/static/sample-screenshot2.jpg?h=1575409895" host=overwatchperfectflex.herokuapp.com request_id=a4798112-a7f5-4ab7-b42e-747efa851bb9 fwd="40.94.96.98" dyno=web.1 connect=0ms service=17ms status=200 bytes=362587 protocol=https
2020-02-21T04:40:20.591308+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=overwatchperfectflex.herokuapp.com request_id=efa578d0-bf07-4915-a038-77b65598387c fwd="40.94.36.97" dyno=web.1 connect=1ms service=2ms status=404 bytes=386 protocol=https
2020-02-21T04:40:21.658366+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=overwatchperfectflex.herokuapp.com request_id=559223ab-da65-439d-b716-246b656d3eaf fwd="40.94.96.98" dyno=web.1 connect=0ms service=5ms status=404 bytes=386 protocol=https
2020-02-21T05:16:18.730746+00:00 heroku[web.1]: Idling
2020-02-21T05:16:18.734547+00:00 heroku[web.1]: State changed from up to down
2020-02-21T05:16:19.783524+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2020-02-21T05:16:19.801722+00:00 app[web.1]: [2020-02-21 05:16:19 +0000] [4] [INFO] Handling signal: term
2020-02-21T05:16:19.802039+00:00 app[web.1]: [2020-02-21 05:16:19 +0000] [30] [INFO] Worker exiting (pid: 30)
2020-02-21T05:16:19.802390+00:00 app[web.1]: [2020-02-21 05:16:19 +0000] [22] [INFO] Worker exiting (pid: 22)
2020-02-21T05:16:19.809300+00:00 app[web.1]: [2020-02-21 05:16:19 +0000] [14] [INFO] Worker exiting (pid: 14)
2020-02-21T05:16:19.935558+00:00 app[web.1]: [2020-02-21 05:16:19 +0000] [4] [INFO] Shutting down: Master
2020-02-21T05:16:20.000313+00:00 heroku[web.1]: Process exited with status 0
2020-02-21T17:24:37.126304+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=overwatchperfectflex.herokuapp.com request_id=21677fce-34ce-4437-94ce-31692db20bce fwd="66.249.84.169,66.102.6.200" dyno= connect= service= status=503 bytes= protocol=https
2020-02-21T17:24:52.887916+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=overwatchperfectflex.herokuapp.com request_id=cbbfe77c-8cf4-4b72-a0e2-865e644bfaa3 fwd="66.201.50.243,66.102.6.201" dyno= connect= service= status=503 bytes= protocol=http

我的应用程序在heroku上托管了几个月后,几天前它就随机关闭了。我最近没有对代码库做任何更改。我已经附上了我认为有关这个问题的相关日志。我已经做了我的研究,显然如果你的应用程序没有获得足够的流量,heroku会自动这样做,但我相信这是错误的,因为我以前在heroku上主持的项目仍然可以正常工作

*如果在本地托管,我的应用程序可以完美运行


Tags: pathcomidapphostgetherokurequest
1条回答
网友
1楼 · 发布于 2024-10-01 22:42:12

第一:

heroku[router]: at=error code=H10 desc="App crashed"

Heroku Error Code docs中,H10表示“应用程序崩溃”:

A crashed web dyno or a boot timeout on the web dyno will present this error.

2010-10-06T21:51:10-07:00 heroku[web.1]: Process exited  
2010-10-06T21:51:12-07:00 heroku[router]: at=error code=H10 desc="App  
crashed" method=GET path="/" host=myapp.herokuapp.com fwd=17.17.17.17
dyno= connect= service= status=503 bytes= 

第二:

你似乎在使用一个自由的二元体,即goes to sleep after a 30-minute period of no activity

2020-02-21T04:40:21.658366+00:00 heroku[router] ... (last access) ...  
2020-02-21T05:16:18.730746+00:00 heroku[web.1]: Idling  
2020-02-21T05:16:18.734547+00:00 heroku[web.1]: State changed from up to down  
2020-02-21T05:16:19.783524+00:00 heroku[web.1]: Stopping all processes with SIGTERM

除了买不睡觉的dynos,你什么都做不了。当dyno进入睡眠状态时,它会停止该dyno上运行的所有进程,包括您的应用程序

2020-02-21T05:16:19.783524+00:00 heroku[web.1]: Stopping all processes with SIGTERM 
2020-02-21T05:16:19.801722+00:00 app[web.1]: [2020-02-21 05:16:19 +0000] [4] [INFO] Handling signal: term  
2020-02-21T05:16:19.802039+00:00 app[web.1]: [2020-02-21 05:16:19 +0000] [30] [INFO] Worker exiting (pid: 30) 
2020-02-21T05:16:19.802390+00:00 app[web.1]: [2020-02-21 05:16:19 +0000] [22] [INFO] Worker exiting (pid: 22)  
2020-02-21T05:16:19.809300+00:00 app[web.1]: [2020-02-21 05:16:19 +0000] [14] [INFO] Worker exiting (pid: 14)  
2020-02-21T05:16:19.935558+00:00 app[web.1]: [2020-02-21 05:16:19 +0000] [4] [INFO] Shutting down: Master  
2020-02-21T05:16:20.000313+00:00 heroku[web.1]: Process exited with status 0 

现在,当Heroku向您的应用程序发送SIGTERM信号时,在异常终止(SIGTERM)和应用程序重新启动之间发生了一些事情,导致应用程序崩溃。也许你的应用程序未能处理一个不太优雅的退出(例如文件I/O,数据库连接未关闭),所以从异常状态重新启动导致它崩溃

2020-02-21T17:24:37.126304+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=overwatchperfectflex.herokuapp.com request_id=21677fce-34ce-4437-94ce-31692db20bce fwd="66.249.84.169,66.102.6.200" dyno= connect= service= status=503 bytes= protocol=https 

所以

*My app works perfectly if hosted locally.

太好了

也许你还需要检查当你的应用程序异常终止时会发生什么。在本地运行它,然后发送相同的SIGTERM信号。获取应用程序的PID,然后查看How can I send a signal from a python program?

相关问题 更多 >

    热门问题