2016-08-04 36 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。

希望有幫助!