第一次 Heroku 部署失败 `error code=H10` [英] First Heroku deploy failed `error code=H10`
本文介绍了第一次 Heroku 部署失败 `error code=H10`的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我将我的应用部署到 Heroku.这是一个 node.js + express + socket.io 应用程序,这是 package.json
文件
I deployed my app to Heroku. It's a node.js + express + socket.io app and this is the package.json
file
{
"name": "game_test",
"author": "Ilya",
"description": "A test app for our board game",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node app"
},
"dependencies": {
"express": "3.0.6",
"jade": "*",
"socket.io" : "*"
},
"engines": {
"node": "0.8.14"
}
}
这是我得到的日志:
heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=game-test-1.herokuapp.com fwd=37.26.146.185 dyno= queue= wait= connect= service= status=503 bytes=
heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=game-test-1.herokuapp.com fwd=37.26.146.185 dyno= queue= wait= connect= service= status=503 bytes=
什么意思?
推荐答案
在这里为我找到了解决方案:Heroku + node.js 错误(Web 进程未能在启动后 60 秒内绑定到 $PORT)
Found solution for me here: Heroku + node.js error (Web process failed to bind to $PORT within 60 seconds of launch)
在我的例子中,我的应用程序崩溃了,因为我很难设置端口,而不是使用 heroku dinamicaly 设置的端口,该端口可以通过 process.env.PORT
In my case my app crashed because I was hard setting the PORT, instead of using the port that heroku dinamicaly sets, which can be accessed with 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);
});
这篇关于第一次 Heroku 部署失败 `error code=H10`的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文