2016-08-04 24 views
1

第一次使用Heroko。遵循这些步骤,我的构建成功了,但是当我转到URL时,出现应用程序错误。我看着在日志中,但我真的不知道发生了什么,下面是我Heroko节点js的应用程序错误

2016-08-04T14:24:15.352519+00:00 heroku[web.1]: State changed from crashed to starting 
2016-08-04T14:24:31.776384+00:00 heroku[web.1]: Starting process with command `node server.js` 
2016-08-04T14:24:34.211793+00:00 app[web.1]: keyword api listening at http://[::]:8088 
2016-08-04T14:25:32.328147+00:00 heroku[web.1]: Stopping process with SIGKILL 
2016-08-04T14:25:32.327930+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch 
2016-08-04T14:25:32.501167+00:00 heroku[web.1]: State changed from starting to crashed 
2016-08-04T14:25:32.503024+00:00 heroku[web.1]: State changed from crashed to starting 
2016-08-04T14:25:32.477573+00:00 heroku[web.1]: Process exited with status 137 
2016-08-04T14:25:36.445941+00:00 heroku[web.1]: Starting process with command `node server.js` 
2016-08-04T14:25:39.335482+00:00 app[web.1]: keyword api listening at http://[::]:8088 
2016-08-04T14:26:37.186681+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch 
2016-08-04T14:26:37.186681+00:00 heroku[web.1]: Stopping process with SIGKILL 
2016-08-04T14:26:37.329330+00:00 heroku[web.1]: Process exited with status 137 
2016-08-04T14:26:37.353704+00:00 heroku[web.1]: State changed from starting to crashed 
2016-08-04T14:26:37.619772+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=shielded-temple-17247.herokuapp.com request_id=db8eb419-e950-4768-8a3f-319a84f7d4e2 fwd="2.125.30.1" dyno= connect= service= status=503 bytes= 
2016-08-04T14:26:38.809203+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=shielded-temple-17247.herokuapp.com request_id=5661b532-80af-40cb-8ae3-0bf9868b5e0f fwd="2.125.30.1" dyno= connect= service= status=503 bytes= 
+0

好像你对使用你的应用程序的端口有问题。 Heroku在开始运行时设置了不同的端口。 –

回答

0

日志列表中你有什么在你Procfile界定?现在,它似乎是这样的:

web: node server.js 

Procfile讲述的Heroku如何运行你的应用程序。您显示的日志表明您尝试在端口8088上运行节点服务器 - 这可能是问题所在。

Heroku不允许你在你想要的任何端口上运行你的服务器 - 相反,它会动态地告诉你什么端口在应用程序启动时运行你的服务器。它通过使用名为PORT的环境变量来完成此操作。

您需要做的是修改您的server.js代码,以便您在process.env.PORT上启动服务器。

下面是一个例子(express.js):

var express = require('express'); 

var app = express(); 

app.listen(process.env.PORT); 

这将成功地自动绑定到正确的端口启动节点服务器在Heroku。

希望有帮助!