代码之家  ›  专栏  ›  技术社区  ›  Bernardo Dal Corno

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

  •  -1
  • Bernardo Dal Corno  · 技术社区  · 6 年前

    我正在使用进程。环境。端口,并显示在日志中(请参阅下面的localhost:40170,每次运行应用程序时都会更改)。此外,加载时间很快(10秒),因为我没有在node start中运行任何构建过程。运行heroku local runs应用程序很好。请帮助我找到导致此问题的原因。

    以下是日志:

    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 回复  |  直到 6 年前
        1
  •  1
  •   Paul    6 年前

    如果没有看到您的一些代码,就不可能知道。如果不得不猜测的话,您在本地满足的依赖关系在服务器上并不满足,例如DH连接,或者您没有在包中包含模块。本地安装的json(如全局安装)

        2
  •  1
  •   Bernardo Dal Corno    6 年前

    解决它:除了 Paul's answer ,还有别的事情。

    我改变了 host 我的Hapi服务器选项 '0.0.0.0' 'localhost' (可能是因为它没有在本地运行)。根据 Hapi's API reference ,这是自动完成的-首先尝试计算机名,然后尝试“localhost”。

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

        3
  •  0
  •   Piyush Jain    6 年前
    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.