0

i went through this code (sample of node-cluster), its working fine without errors, but no response from http server. as per logs it was created workers and those are running

var cluster = require('cluster')
  , http = require('http');

var server = http.createServer(function(req, res){
  console.log('%s %s', req.method, req.url);
  var body = 'Hello World';
  res.writeHead(200, { 'Content-Length': body.length });
  res.end(body);
});

cluster(server)
  .use(cluster.logger('logs'))
  .use(cluster.stats())
  .use(cluster.pidfiles('pids'))
  .use(cluster.cli())
  .use(cluster.repl(8888))
  .listen(3000);
4

1 回答 1

0

刚刚在节点 0.4.12 上测试了您的代码,它工作正常。我试图提出一个请求,它会按原样curl返回。Hello world

您确定没有错误并且您拥有节点版本 0.4?如果我没记错的话,他们从 0.5 开始就添加了内置集群功能。

于 2012-05-02T11:54:33.580 回答