尝试在heroku中部署节点应用程序时不断收到应用程序错误

时间:2015-10-27 20:46:57

标签: node.js heroku

我在heroku上部署时遇到了困难。跟随在heroku指南上部署节点js应用程序但仍然不断收到应用程序错误。任何想法为什么请?这是我的heroku日志

 heroku logs
2015-10-27T19:48:35.704758+00:00 heroku[api]: Enable Logplex by chineduabalogu@gmail.com
2015-10-27T19:48:35.704758+00:00 heroku[api]: Release v2 created by chineduabalogu@gmail.com
2015-10-27T19:57:58.536860+00:00 heroku[slug-compiler]: Slug compilation started
2015-10-27T19:57:58.536871+00:00 heroku[slug-compiler]: Slug compilation finished
2015-10-27T19:57:58.397214+00:00 heroku[api]: Scale to web=1 by chineduabalogu@gmail.com
2015-10-27T19:57:58.466140+00:00 heroku[api]: Deploy 51bdb1d by chineduabalogu@gmail.com
2015-10-27T19:57:58.466140+00:00 heroku[api]: Release v3 created by chineduabalogu@gmail.com
2015-10-27T19:58:00.692453+00:00 heroku[web.1]: Starting process with command `npm start`
2015-10-27T19:58:03.827532+00:00 app[web.1]: 
2015-10-27T19:58:03.827554+00:00 app[web.1]: > node app.js
2015-10-27T19:58:03.827552+00:00 app[web.1]: > gf17@0.0.1 start /app
2015-10-27T19:58:03.827555+00:00 app[web.1]: 
2015-10-27T19:58:04.616168+00:00 app[web.1]: Express server listening on port 3000
2015-10-27T19:59:00.972722+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2015-10-27T19:59:00.972722+00:00 heroku[web.1]: Stopping process with SIGKILL
2015-10-27T19:59:01.940288+00:00 heroku[web.1]: State changed from starting to crashed
2015-10-27T19:59:01.941567+00:00 heroku[web.1]: State changed from crashed to starting
2015-10-27T19:59:01.932037+00:00 heroku[web.1]: Process exited with status 137
2015-10-27T19:59:04.247002+00:00 heroku[web.1]: Starting process with command `npm start`
2015-10-27T19:59:07.923766+00:00 app[web.1]: 
2015-10-27T19:59:07.923776+00:00 app[web.1]: > gf17@0.0.1 start /app
2015-10-27T19:59:07.923778+00:00 app[web.1]: > node app.js
2015-10-27T19:59:07.923779+00:00 app[web.1]: 
2015-10-27T19:59:09.513389+00:00 app[web.1]: Express server listening on port 3000
2015-10-27T20:00:04.705994+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2015-10-27T20:00:04.705994+00:00 heroku[web.1]: Stopping process with SIGKILL
2015-10-27T20:00:05.657468+00:00 heroku[web.1]: State changed from starting to crashed
2015-10-27T20:00:05.644215+00:00 heroku[web.1]: Process exited with status 137
2015-10-27T20:17:45.559370+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=evening-fjord-8286.herokuapp.com request_id=ce9f7865-5431-4514-83e3-9228df351291 fwd="154.118.30.203" dyno= connect= service= status=503 bytes=
2015-10-27T20:17:46.110795+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=evening-fjord-8286.herokuapp.com request_id=e7b1f9b7-4600-4ce7-b90c-3239a82abcb9 fwd="154.118.30.203" dyno= connect= service= status=503 bytes=
2015-10-27T20:17:48.086903+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=evening-fjord-8286.herokuapp.com request_id=8a41518c-cfd8-4dac-8622-1f94de9346b3 fwd="198.15.118.148" dyno= connect= service= status=503 bytes=
2015-10-27T20:17:48.543167+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=evening-fjord-8286.herokuapp.com request_id=e1ce271b-7a76-43c1-931e-0ac9a375cfb7 fwd="154.118.30.203" dyno= connect= service= status=503 bytes=
2015-10-27T20:19:48.784831+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=evening-fjord-8286.herokuapp.com request_id=9229308a-6604-4426-8ba6-4cabb8b94de9 fwd="154.118.30.203" dyno= connect= service= status=503 bytes=
2015-10-27T20:19:49.552910+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=evening-fjord-8286.herokuapp.com request_id=e542cc92-ca00-4044-8c23-76642887ef35 fwd="154.118.30.203" dyno= connect= service= status=503 bytes=
2015-10-27T20:22:17.304691+00:00 heroku[web.1]: State changed from crashed to starting
2015-10-27T20:22:19.261727+00:00 heroku[web.1]: Starting process with command `npm start`
2015-10-27T20:22:21.447920+00:00 app[web.1]: 
2015-10-27T20:22:21.447934+00:00 app[web.1]: > gf17@0.0.1 start /app
2015-10-27T20:22:21.447935+00:00 app[web.1]: > node app.js
2015-10-27T20:22:21.447936+00:00 app[web.1]: 
2015-10-27T20:22:22.123539+00:00 app[web.1]: Express server listening on port 3000
2015-10-27T20:23:19.916089+00:00 heroku[web.1]: Stopping process with SIGKILL
2015-10-27T20:23:19.916089+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2015-10-27T20:23:20.780482+00:00 heroku[web.1]: Process exited with status 137
2015-10-27T20:23:20.792567+00:00 heroku[web.1]: State changed from starting to crashed
2015-10-27T20:25:54.984210+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=evening-fjord-8286.herokuapp.com request_id=83eec29d-598c-44d1-b6bc-55933e60013f fwd="154.118.30.203" dyno= connect= service= status=503 bytes=
2015-10-27T20:25:56.659875+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=evening-fjord-8286.herokuapp.com request_id=c384f7e6-e6e9-4088-bdf1-b7370b572b68 fwd="154.118.30.203" dyno= connect= service= status=503 bytes=

1 个答案:

答案 0 :(得分:1)

从您的日志中,您似乎没有绑定到正确的端口。

我将假设您的Express.js应用程序看起来像这样:

app.listen(3000);

这行代码告诉Express.js开始在端口3000上运行Web服务器。当您在笔记本电脑上编写代码时这很好,但是当您将代码部署到Heroku时,Heroku会为您分配一个RANDOM端口号你必须绑定到。

因此,为了解决您的问题,您应该重写上面的代码行,如下所示:

app.listen(process.env.PORT || 3000);

这将告诉您的应用程序在正确的Heroku端口上运行,但在本地笔记本电脑上进行开发时会回退到端口3000 =)这是两全其美的。

希望这有帮助!