在Cloud9和Heroku上启动Node应用程序

时间:2018-05-30 17:50:59

标签: heroku cloud9

我正在使用以下内容在Cloud9上启动Node应用程序而不会遇到可怕的错误端口或IP警告,除非我将IP地址指定为process.env.IP,否则我会得到:

app.listen(PORT, process.env.IP || 'localhost', function () {
  console.info(`Server listening on ${this.address().address}:${this.address().port}`);
}).on("error", err => {
  console.error(err);
});

但是,我想知道何时将其部署到Heroku并且process.env.IP未定义,是O.K.在Heroku上IP将默认为localhost

当我尝试在Heroku上运行时,我从console.info获取此信息:

Server listening on 127.0.0.1:23128

但是我在Heroku日志中遇到以下错误:

2018-05-31T04:36:26.982797+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2018-05-31T04:36:26.982904+00:00 heroku[web.1]: Stopping process with SIGKILL
2018-05-31T04:36:27.097924+00:00 heroku[web.1]: State changed from starting to crashed
2018-05-31T04:36:27.074917+00:00 heroku[web.1]: Process exited with status 137
2018-05-31T04:37:18.807726+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=ancient-anchorage-15597.herokuapp.com request_id=f893c181-f406-4319-b2f2-938548ba4ff0 fwd="72.0.178.64" dyno= connect= service= status=503 bytes= protocol=https

0 个答案:

没有答案
相关问题