首页 > 解决方案 > Heroku 在构建结束时没有显示我的应用程序

问题描述

我曾尝试使用Heroku在项目中进行持续集成/部署。我尝试按照一个简单的 youtube 视频来上传我的 node.JS 应用程序,我一直到最后,您通过 Heroku 单击查看应用程序,我得到了一个巨大的错误日志(如下所示),我不知道在哪里开始调试,有人能解释一下吗?

Kayleighs-MBP:SOFT355-HangMan Kayleigh$ heroku logs --tail
 ›   Warning: heroku update available from 7.35.0 to 7.35.1.
2020-01-04T14:05:16.981790+00:00 app[api]: Enable Logplex by user kayz_haydock@hotmail.co.uk
2020-01-04T14:05:16.822338+00:00 app[api]: Release v1 created by user kayz_haydock@hotmail.co.uk
2020-01-04T14:05:16.981790+00:00 app[api]: Release v2 created by user kayz_haydock@hotmail.co.uk
2020-01-04T14:05:16.822338+00:00 app[api]: Initial release by user kayz_haydock@hotmail.co.uk
2020-01-04T14:18:46.000000+00:00 app[api]: Build started by user kayz_haydock@hotmail.co.uk
2020-01-04T14:19:18.680353+00:00 app[api]: Release v3 created by user kayz_haydock@hotmail.co.uk
2020-01-04T14:19:18.680353+00:00 app[api]: Deploy ff30f369 by user kayz_haydock@hotmail.co.uk
2020-01-04T14:19:18.695708+00:00 app[api]: Scaled to web@1:Free by user kayz_haydock@hotmail.co.uk
2020-01-04T14:19:20.000000+00:00 app[api]: Build succeeded
2020-01-04T14:19:22.117990+00:00 heroku[web.1]: Starting process with command `npm start`
2020-01-04T14:19:25.409179+00:00 app[web.1]: 
2020-01-04T14:19:25.409202+00:00 app[web.1]: > SOFT355-HangMan@1.0.0 start /app
2020-01-04T14:19:25.409204+00:00 app[web.1]: > node hangman-server.js
2020-01-04T14:19:25.409205+00:00 app[web.1]: 
2020-01-04T14:19:56.058173+00:00 app[web.1]: (node:23) UnhandledPromiseRejectionWarning: MongoTimeoutError: Server selection timed out after 30000 ms
2020-01-04T14:19:56.058209+00:00 app[web.1]: at Timeout._onTimeout (/app/node_modules/mongodb/lib/core/sdam/server_selection.js:308:9)
2020-01-04T14:19:56.058212+00:00 app[web.1]: at listOnTimeout (internal/timers.js:531:17)
2020-01-04T14:19:56.058214+00:00 app[web.1]: at processTimers (internal/timers.js:475:7)
2020-01-04T14:19:56.058439+00:00 app[web.1]: (node:23) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
2020-01-04T14:19:56.058598+00:00 app[web.1]: (node:23) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
2020-01-04T14:20:22.338538+00:00 heroku[web.1]: State changed from starting to crashed
2020-01-04T14:20:22.407927+00:00 heroku[web.1]: State changed from crashed to starting
2020-01-04T14:20:22.219187+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2020-01-04T14:20:22.219426+00:00 heroku[web.1]: Stopping process with SIGKILL
2020-01-04T14:20:22.325559+00:00 heroku[web.1]: Process exited with status 137
2020-01-04T14:20:25.204227+00:00 heroku[web.1]: Starting process with command `npm start`
2020-01-04T14:20:27.500815+00:00 app[web.1]: 
2020-01-04T14:20:27.500828+00:00 app[web.1]: > SOFT355-HangMan@1.0.0 start /app
2020-01-04T14:20:27.500830+00:00 app[web.1]: > node hangman-server.js
2020-01-04T14:20:27.500831+00:00 app[web.1]: 
2020-01-04T14:20:38.708137+00:00 heroku[router]: at=error code=H20 desc="App boot timeout" method=GET path="/" host=soft355-hangman-heroku.herokuapp.com request_id=15d0e236-af32-44ae-aae8-5a6cb342c260 fwd="90.200.113.10" dyno= connect= service= status=503 bytes= protocol=https
2020-01-04T14:20:57.961209+00:00 app[web.1]: (node:23) UnhandledPromiseRejectionWarning: MongoTimeoutError: Server selection timed out after 30000 ms
2020-01-04T14:20:57.961225+00:00 app[web.1]: at Timeout._onTimeout (/app/node_modules/mongodb/lib/core/sdam/server_selection.js:308:9)
2020-01-04T14:20:57.961228+00:00 app[web.1]: at listOnTimeout (internal/timers.js:531:17)
2020-01-04T14:20:57.961229+00:00 app[web.1]: at processTimers (internal/timers.js:475:7)
2020-01-04T14:20:57.961471+00:00 app[web.1]: (node:23) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
2020-01-04T14:20:57.961541+00:00 app[web.1]: (node:23) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
2020-01-04T14:21:25.939157+00:00 heroku[web.1]: State changed from starting to crashed
2020-01-04T14:21:25.848388+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2020-01-04T14:21:25.848490+00:00 heroku[web.1]: Stopping process with SIGKILL
2020-01-04T14:21:25.924978+00:00 heroku[web.1]: Process exited with status 137
2020-01-04T14:21:28.031213+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=soft355-hangman-heroku.herokuapp.com request_id=84fc9ea0-a4e9-4c65-8357-2ef4218f2054 fwd="90.200.113.10" dyno= connect= service= status=503 bytes= protocol=https
2020-01-04T14:21:28.670209+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=soft355-hangman-heroku.herokuapp.com request_id=ab8bb069-da76-4766-830f-e81a80dce8d3 fwd="90.200.113.10" dyno= connect= service= status=503 bytes= protocol=https
2020-01-04T14:21:29.277077+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=soft355-hangman-heroku.herokuapp.com request_id=66dbc233-0e2f-4c39-ba98-3cae75ae03b7 fwd="90.200.113.10" dyno= connect= service= status=503 bytes= protocol=https
2020-01-04T14:24:34.028234+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=soft355-hangman-heroku.herokuapp.com request_id=3fb5fa25-9a46-4b11-b5b0-5df9483c1eed fwd="90.200.113.10" dyno= connect= service= status=503 bytes= protocol=https

标签: node.jsheroku

解决方案


这是你开始的地方:

Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch

您是硬编码端口还是使用默认端口(8080)?Heroku 运行时为您提供了一个环境变量 PORT,您应该使用它来绑定您的应用程序并接受传入的请求。


推荐阅读