簡體   English   中英

無法在heroku上部署節點應用程序。 僅顯示歡迎消息

[英]Unable to deploy node app on heroku. Displays only welcome message

heroku日志

 2018-04-20T20:45:50.151330+00:00 app[api]: Enable Logplex by user ghsklat2378123@gmail.com
 2018-04-20T20:45:50.059558+00:00 app[api]: Release v1 created by user ghsklat2378123@gmail.com
 2018-04-20T20:45:50.059558+00:00 app[api]: Initial release by user ghsklat2378123@gmail.com
 2018-04-20T20:45:50.151330+00:00 app[api]: Release v2 created by user ghsklat2378123@gmail.com
 2018-04-20T20:46:48.000000+00:00 app[api]: Build started by user ghsklat2378123@gmail.com
 2018-04-20T20:46:58.098188+00:00 app[api]: Deploy 2b289e67 by user ghsklat2378123@gmail.com
 2018-04-20T20:46:58.098188+00:00 app[api]: Release v3 created by user ghsklat2378123@gmail.com
 2018-04-20T20:46:48.000000+00:00 app[api]: Build succeeded
 2018-04-20T20:46:58.115335+00:00 app[api]: Scaled to web@1:Free by user ghsklat2378123@gmail.com
 2018-04-20T20:47:00.895268+00:00 heroku[web.1]: Starting process with command `npm start`
 2018-04-20T20:47:03.518908+00:00 app[web.1]: 
 2018-04-20T20:47:03.518933+00:00 app[web.1]: > node server.js
 2018-04-20T20:47:03.518931+00:00 app[web.1]: > stywqrrd@1.0.0 start /app
 2018-04-20T20:47:03.518935+00:00 app[web.1]: 
 2018-04-20T20:47:03.875652+00:00 app[web.1]: Express server listening on port 3000
 2018-04-20T20:48:01.013365+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
 2018-04-20T20:48:01.013866+00:00 heroku[web.1]: Stopping process with SIGKILL
 2018-04-20T20:48:01.152301+00:00 heroku[web.1]: State changed from starting to crashed
 2018-04-20T20:48:01.155261+00:00 heroku[web.1]: State changed from crashed to starting
 2018-04-20T20:48:01.132422+00:00 heroku[web.1]: Process exited with status 137
 2018-04-20T20:48:02.894892+00:00 heroku[web.1]: Starting process with command `npm start`
 2018-04-20T20:48:05.106690+00:00 app[web.1]: 
 2018-04-20T20:48:05.106708+00:00 app[web.1]: > sstywqrrd@1.0.0 start /app
 2018-04-20T20:48:05.106710+00:00 app[web.1]: > node server.js
 2018-04-20T20:48:05.106712+00:00 app[web.1]: 
 2018-04-20T20:48:05.295340+00:00 app[web.1]: Express server listening on port 3000

這是我無法部署的非常簡單的節點應用程序。 當我獲得鏈接時,它將顯示: heroku welcome to you new app. Refer to documentation if you need help deploying heroku welcome to you new app. Refer to documentation if you need help deploying 日志不顯示任何錯誤(所有日志均顯示為藍色)。 我該如何解決?

克隆倉庫,然后執行git init,git add,git commit

heroku create
heroku git:remote -a safe-forest-59278
heroku apps:create myappName
git push heroku master

根據對帳單

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

這僅表示您嘗試連接的端口由於某種原因不可用。

而且最有可能您正在指定端口,例如

port = 3000

您應該將此行更改為

port = process.env.PORT || 3000

這將讓heroku服務器為您的服務器分配一個可用端口以進行監聽。

發生這種情況的原因是,大多數情況下是因為您在開發應用程序時指定了端口,所以這些端口很少有機會在生產中可用並打開。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM