簡體   English   中英

Heroku“進程以狀態 137 退出”node.js 應用程序

[英]Heroku "Process exited with status 137" node.js app

我最近發布了一個關於類似主題的問題。 我對 URL 上的所有內容進行了大修,並且發生了與上次相同的事情:我可以部署所有內容並使用heroku local web運行它。 當我訪問 web dyno 時,它說我有一個應用程序錯誤,然后我檢查了日志。 這是它所說的(我在 github 上使用一個名為 atwork 的項目):

2017-05-02T02:35:39.191493+00:00 app[web.1]: Loaded model: chats.js
2017-05-02T02:35:39.200517+00:00 app[web.1]: Loaded model: streams.js
2017-05-02T02:35:39.196830+00:00 app[web.1]: Loaded model: posts.js
2017-05-02T02:35:39.209761+00:00 app[web.1]: Loaded model: users.js
2017-05-02T02:35:40.067321+00:00 app[web.1]: AtWork running at http://:::8111
2017-05-02T02:35:50.116492+00:00 heroku[router]: at=error code=H20 desc="App boot timeout" method=GET path="/" host=room111-thoughts.herokuapp.com request_id=44a6e779-e6b8-4a33-a5b9-53430af2ad8f fwd="108.221.62.78" dyno= connect= service= status=503 bytes= protocol=https
2017-05-02T02:36:35.859814+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2017-05-02T02:36:35.859903+00:00 heroku[web.1]: Stopping process with SIGKILL
2017-05-02T02:36:35.956564+00:00 heroku[web.1]: Process exited with status 137
2017-05-02T02:36:35.969766+00:00 heroku[web.1]: State changed from starting to crashed
2017-05-02T02:37:22.933285+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=room111-thoughts.herokuapp.com request_id=80ffc71f-d792-4538-b50a-5140b7658819 fwd="108.221.62.78" dyno= connect= service= status=503 bytes= protocol=https

我是 Heroku 和 Node.js 的初學者,非常感謝您的幫助。 我將提供找到答案所需的任何信息。

我檢查了日志,它說at=error code=H10 desc="App crashed" ,這意味着你有uncaught Exception ,所以你應該檢查你的代碼。

如果你想在 Heroku 上使用mongodb ,你應該嘗試為你的應用程序添加mongodb addon 你可以在這里找到文檔

並嘗試使用process.env.PORT ,而不是您要使用的端口。

如果仍然不能解決你的問題,你可以嘗試使用這個命令heroku run bash ,這個命令可以讓你進入heroku環境並啟動你的服務器。

在 heroku 上托管 Node 應用程序時我遇到了同樣的錯誤結果是端口問題所以只需將端口設置為等於此

var port = process.env.PORT || 8080;

所以 process.env.PORT || 8080 表示:環境變量 PORT 中的任何內容,如果什么都沒有,則為 8080。

然后在下面設置set port變量

var server=app.listen(port,function() {
console.log("app running on port 8080"); });

這絕對是端口問題。 只需使用這樣的東西:

var port = process.env.PORT || 3002

指定您的端口。

就這樣。

看起來您的應用在實際啟動服務器之前就超時了:

應用啟動超時

縮小生產資產的過程是否會花費太長時間?

暫無
暫無

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

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