部署到Heroku时失败

时间:2017-08-18 15:53:10

标签: node.js heroku

我正在尝试将我的应用程序部署到Heroku。

构建成功但存在应用程序错误。

这是构建日志:

2017-08-19T10:52:32.433135+00:00 heroku[web.1]: State changed from crashed to 
starting

2017-08-19T10:52:20.000000+00:00 app[api]: Build succeeded                                                              

2017-08-19T10:52:34.561890+00:00 heroku[web.1]: Starting process with command 
`node app.js`

2017-08-19T10:52:38.533264+00:00 app[web.1]: (node:4) DeprecationWarning: 
`open()` is deprecated in mongoose >= 4.11.0, use `openUri()` instead, or set 
the `useMongoClient` option if using `connect()` or `createConnection()`. See 
http://mongoosejs.com/docs/connections.html#use-mongo-client

2017-08-19T10:52:38.577755+00:00 app[web.1]: Db.prototype.authenticate method 
will no longer be available in the next major release 3.x as MongoDB 3.6 will 
only allow auth against users in the admin db and will no longer allow 
multiple credentials on a socket. Please authenticate using 
MongoClient.connect with auth credentials.

2017-08-19T10:52:38.879889+00:00 app[web.1]: the data has been seeded

2017-08-19T10:53:38.120507+00:00 heroku[router]: at=error code=H10 desc="App 
crashed" method=GET path="/" host=murmuring-garden-83350.herokuapp.com 
request_id=dae4f901-83d5-442c-bca0-396508c8661e fwd="83.185.242.212" dyno= 
connect= service= status=503 bytes= protocol=https

真的希望有人能指出我正确的方向。感谢。

1 个答案:

答案 0 :(得分:0)

在这里为我找到解决方案:Heroku + node.js error (Web process failed to bind to $PORT within 60 seconds of launch)

在我的情况下,我的应用程序崩溃,因为我很难设置PORT,而不是使用heroku dinamicaly设置的端口,可以使用process.env.PORT访问

 app.listen(process.env.PORT || 3000, function(){
 console.log("Express server listening on port %d in %s mode", 
 this.address().port, app.settings.env);
 });