启动时Heroku应用程序超时(R10) - NodeJs

时间:2018-05-03 03:56:56

标签: node.js heroku hapijs

我正在使用process.env.PORT,并显示在日志中(见下文,localhost:40170,每次运行应用程序时都会更改)。此外,加载时间很快(10秒),因为我没有在节点启动中运行任何构建过程。运行heroku本地运行app很好。请帮我找一下可能导致此问题的原因。

这是日志:

2018-05-03T02:37:04.505544+00:00 app[web.1]: loading routes from ./modules/user.login/auth.routes.js... 2018-05-03T02:37:04.526922+00:00 app[web.1]: loading routes from ./modules/user.login/login.routes.js... 2018-05-03T02:37:04.531738+00:00 app[web.1]: loading routes from ./modules/feature.clientes/clientes.crud.routes.js... 2018-05-03T02:37:04.542719+00:00 app[web.1]: loading routes from ./modules/feature.contratos/contratos.crud.routes.js... 2018-05-03T02:37:04.552200+00:00 app[web.1]: loading routes from ./modules/feature.servicos/servicos.crud.routes.js... 2018-05-03T02:37:04.601525+00:00 app[web.1]: Server running at: http://localhost:40170 2018-05-03T02:38:01.800290+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch 2018-05-03T02:38:01.800290+00:00 heroku[web.1]: Stopping process with SIGKILL 2018-05-03T02:38:01.899194+00:00 heroku[web.1]: Process exited with status 137 2018-05-03T02:38:01.940085+00:00 heroku[web.1]: State changed from starting to crashed

3 个答案:

答案 0 :(得分:1)

没有看到你的一些代码就不可能知道。如果我不得不猜测,你在本地遇到的依赖是你在服务器上不满意,比如DH连接,或者你没有在你的package.json中包含你在本地安装的模块(例如全局安装)

答案 1 :(得分:1)

解决了它:除了Paul's answer之外,还有别的东西。

我已将Hapi服务器的host选项从'0.0.0.0'更改为'localhost'(可能因为它未在本地运行)。根据{{​​3}},这是自动完成的 - 首先它尝试机器名称,然后是#localhost'。

因此,只需删除该设置即可解决问题。现在Heroku记录了类似:Server running at: http://243c893-1ec-48d-bdc4-2ba08a3d59:55296

的内容

答案 2 :(得分:0)

This seems to be happen as because heroku sets dynamic port at which your app runs, as you are using PORT from env you need to add PORT in heroku config vars. Just got through heroku app => settings => view config vars => Add PORT <your port number example 5000> in it.