为什么Heroku应用程序在H10之后崩溃,如何发现问题?

我正在将一个应用程序部署到由mongodb-Atlas托管的Heroku应用程序的node.js,部署后,它开始崩溃。这是事件日志:

2019-11-07T14:03:44.54763+00:00 app[web.1]: 
2019-11-07T14:03:44.547905+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-11-07T14:03:44.548078+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2019-11-07T14_03_43_920Z-debug.log
2019-11-07T14:03:44.609666+00:00 heroku[web.1]: Process exited with status 1
2019-11-07T14:03:44.660116+00:00 heroku[web.1]: State changed from starting to crashed
2019-11-07T14:08:46.771752+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=flix-app-test.herokuapp.com request_id=14978e4f-fb93-44c8-a6c1-294a6a254e1e fwd="84.17.61.226" dyno= connect= service= status=503 bytes= protocol=https
2019-11-07T14:08:47.381666+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=flix-app-test.herokuapp.com request_id=b067c4c5-8b09-44c7-907e-bb2010dd97ec fwd="84.17.61.226" dyno= connect= service= status=503 bytes= protocol=https
2019-11-07T14:15:51.61258+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=flix-app-test.herokuapp.com request_id=5290a4ea-94b1-4d79-a8fe-6709e6cb2a15 fwd="91.168.132.252" dyno= connect= service= status=503 bytes= protocol=https
2019-11-07T14:15:52.254787+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=flix-app-test.herokuapp.com request_id=41f76767-00c8-490c-9c13-22c0906fedb9 fwd="91.168.132.252" dyno= connect= service= status=503 bytes= protocol=https

我发现的有关此H10错误的大多数帖子都指向定义通过Heroku侦听的端口的行上的问题,该端口不接受严格的端口,但是通过以下代码完成了应用的侦听:>

var port = process.env.PORT || 3000;
app.listen(port,"0.0.0.0",function() {
  console.log('Listening on Heroku defined port');
});

代码在本地运行(已仔细检查),但是Heroku应用程序甚至没有加载。数据库正在运行并且可用,我找不到可见的问题。

我想知道如何继续找出代码的哪一部分坏了,或者找出这是Heroku的临时问题。 预先感谢。

wendy6923 回答:为什么Heroku应用程序在H10之后崩溃,如何发现问题?

如果您使用的是ExpressJS,请执行以下操作:

var port = process.env.PORT;
Promise.resolve(app.listen(port)).then(() => {
   console.log("Running!");
});

无论如何,503是服务不可用的HTTP代码。如果以上代码无效,请为错误的路由发布您的路由器和控制器代码。

本文链接:https://www.f2er.com/3143719.html

大家都在问