Node.js Heroku应用程序崩溃,错误R10(启动超时)`heroku restart`无法正常工作

时间:2013-11-25 05:18:27

标签: node.js heroku

使用我发现的示例中的以下代码,我的Heroku Node.js应用程序崩溃了。当我导航到[myapp] .herokuapp.com

时,它没有响应
var http = require('http');
var port = process.env.PORT || 8000;

var counter = 0;

http.createServer(function (req, res) {

// increment the counter for each visitor request
counter=counter+1;

var path = req.url;
console.log("requested=" + path + " counter=" + counter);

res.writeHead(200, {'Content-Type': 'text/html'}); // prepare response headers

res.end(" :) "); 

}).listen(port);

我的procfile是

web: node thenameofmyapp.js

我已完成heroku ps:scale web=1

我有一些依赖关系,但删除它们试图让一个简单的应用程序工作。我当前的package.json是

{
  "name": "thenameofmyapp",
  "version": "0.0.3",
  "dependencies": {
  },
  "engines": {
    "node": "0.10.x",
    "npm": "1.2.x"
  }
}

为什么我的应用无法绑定到端口?

编辑:看起来即使经过多次更新并运行heroku restart,我的应用程序仍在运行不再存在的代码。这是怎么回事?

3 个答案:

答案 0 :(得分:1)

我不完全确定发生了什么,但是当我推送新代码或运行heroku restart时,看起来Heroku没有重新启动。我使用相同的代码创建了一个新的应用程序,它可以工作。

其他人可能想要测试的一个区别是我在推送到新应用之前从我的git repo中删除了node_packages。

答案 1 :(得分:1)

您还可以通过以下方式检查应用程序的运行情况:heroku日志(您必须先安装herokucli)。

答案 2 :(得分:0)

此错误很可能是由无法访问外部资源的进程引起的,或者是由于许多代码依赖性引起的,或者在启动期间进行了多次评估。

相关问题