2016-08-04 137 views
1

我是nodejs的新手,嘗試將一個簡單的文字遊戲部署到heroku。我按照heroku網站上的指示和everyting作品,直到最後一條命令「heroku open」,它打開一個帶有以下消息的Web瀏覽器:嘗試打開heroku應用程序時出現應用程序錯誤消息

「應用程序發生錯誤,您的頁面無法送達,請嘗試

如果您是應用程序所有者,請查看您的日誌以瞭解詳細信息。「

Heroku的日誌顯示:

2016-08-04T18:56:36.552635+00:00 heroku[api]: Enable Logplex by [email protected]  .com 
2016-08-04T18:56:36.552635+00:00 heroku[api]: Release v2 created by [email protected]  mail.com 
2016-08-04T18:58:34.328360+00:00 heroku[router]: at=info code=H81 desc="Blank ap  p" method=GET path="/" host=build-word-game.herokuapp.com request_id=f238942c-ef  aa-4011-b505-7e5f062221a3 fwd="107.77.75.83" dyno= connect= service= status=502  bytes= 
2016-08-04T18:58:35.171645+00:00 heroku[router]: at=info code=H81 desc="Blank ap  p" method=GET path="/favicon.ico" host=build-word-game.herokuapp.com request_id=  a02c27ef-865c-48e3-91cd-bd6e29ca51e3 fwd="107.77.75.83" dyno= connect= service=  status=502 bytes= 
2016-08-04T19:26:43.069903+00:00 heroku[api]: Scale to web=1 by [email protected]  .com 
2016-08-04T19:26:43.070467+00:00 heroku[api]: Deploy 4725c48 by [email protected]  .com 
2016-08-04T19:26:43.070552+00:00 heroku[api]: Release v3 created by [email protected]  mail.com 
2016-08-04T19:26:43.473784+00:00 heroku[slug-compiler]: Slug compilation finishe  d 
2016-08-04T19:26:43.473765+00:00 heroku[slug-compiler]: Slug compilation started 
2016-08-04T19:26:45.915539+00:00 heroku[web.1]: Starting process with command `n  ode server.js` 
2016-08-04T19:26:50.481084+00:00 app[web.1]: listening to port 3000! 
2016-08-04T19:27:46.488886+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web  process failed to bind to $PORT within 60 seconds of launch 
2016-08-04T19:27:46.488886+00:00 heroku[web.1]: Stopping process with SIGKILL 
2016-08-04T19:27:46.631684+00:00 heroku[web.1]: Process exited with status 137 
2016-08-04T19:27:46.618404+00:00 heroku[web.1]: State changed from starting to c  rashed 
2016-08-04T19:27:46.619564+00:00 heroku[web.1]: State changed from crashed to st  arting 
2016-08-04T19:27:48.599634+00:00 heroku[web.1]: Starting process with command `n  ode server.js` 
2016-08-04T19:27:51.304417+00:00 app[web.1]: listening to port 3000! 
2016-08-04T19:28:48.755864+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web  process failed to bind to $PORT within 60 seconds of launch 
2016-08-04T19:28:48.755938+00:00 heroku[web.1]: Stopping process with SIGKILL 
2016-08-04T19:28:48.879934+00:00 heroku[web.1]: Process exited with status 137 
2016-08-04T19:28:48.893371+00:00 heroku[web.1]: State changed from starting to c  rashed 
2016-08-04T19:31:31.210359+00:00 heroku[router]: at=error code=H10 desc="App cra  shed" method=GET path="/" host=build-word-game.herokuapp.com request_id=e0536d30  -8590-453d-9a04-fb8a56eb6893 fwd="107.77.213.153" dyno= connect= service= status  =503 bytes= 
2016-08-04T19:31:32.552715+00:00 heroku[router]: at=error code=H10 desc="App cra  shed" method=GET path="/favicon.ico" host=build-word-game.herokuapp.com request_  id=89bfb417-9793-4687-b400-72cc34d16ea8 fwd="107.77.213.153" dyno= connect= serv  ice= status=503 bytes= 
2016-08-04T19:53:16.445270+00:00 heroku[web.1]: State changed from crashed to st  arting 
2016-08-04T19:53:18.025971+00:00 heroku[web.1]: Starting process with command `n  ode server.js` 
2016-08-04T19:53:19.981109+00:00 app[web.1]: listening to port 3000! 
2016-08-04T19:54:18.509309+00:00 heroku[web.1]: Stopping process with SIGKILL 
2016-08-04T19:54:18.509204+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web  process failed to bind to $PORT within 60 seconds of launch 
2016-08-04T19:54:18.601875+00:00 heroku[web.1]: Process exited with status 137 
2016-08-04T19:54:18.606261+00:00 heroku[web.1]: State changed from starting to c  rashed 
2016-08-04T19:59:58.452903+00:00 heroku[router]: at=error code=H10 desc="App cra  shed" method=GET path="/" host=build-word-game.herokuapp.com request_id=450b80d9  -a366-4e0f-9426-ff89eac931fb fwd="107.77.213.153" dyno= connect= service= status  =503 bytes= 
2016-08-04T19:59:59.109794+00:00 heroku[router]: at=error code=H10 desc="App cra  shed" method=GET path="/favicon.ico" host=build-word-game.herokuapp.com request_  id=1eecc47a-5334-4a38-bd8d-093a9164ead5 fwd="107.77.213.153" dyno= connect= serv  ice= status=503 bytes= 
2016-08-04T20:01:28.744667+00:00 heroku[router]: at=error code=H10 desc="App cra  shed" method=GET path="/" host=build-word-game.herokuapp.com request_id=a2d52aea  -d7fc-4f18-b023-50aa8e93587c fwd="107.77.213.153" dyno= connect= service= status  =503 bytes= 
2016-08-04T20:01:29.378063+00:00 heroku[router]: at=error code=H10 desc="App cra  shed" method=GET path="/favicon.ico" host=build-word-game.herokuapp.com request_  id=8e62ab9c-50a3-43eb-9579-9c3d4a6c9d42 fwd="107.77.213.153" dyno= connect= serv  ice= status=503 bytes= 

我感謝你的幫助。

+0

嘗試部署在Heroku上的Node.js /快速/ Socket.io應用程序時,[應用程序錯誤的可能的複製](http://stackoverflow.com/questions/24946673/application-error-when-attempting-to-deploy-node-js-express-socket-io-applicatio) – hunterloftis

回答

0

它看起來像您的節點應用程序無法正常啓動。這可能是由於您沒有將您的節點服務器綁定到正確的端口。

在Heroku上,您必須將您的節點服務器綁定到在PORT環境變量中指定的端口號。這是因爲Heroku奇蹟般地處理您的請求的路由,在包含許多其他應用程序的服務器上。

你應該做的是修改你的節點代碼,以便它監聽端口process.env.PORT

下面是一個例子Express.js應用程序中偵聽到正確的端口,作爲一個例子:

var express = require('express'); 

var app = express(); 

app.listen(process.env.PORT); 
相關問題