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);
Steve Bennett
  • 114,604
  • 39
  • 168
  • 219
Ganesh Kumar
  • 1,341
  • 11
  • 18

1 Answers1

0

Just tested your code on node 0.4.12, it works fine. I tried to make a request with curl and it returns Hello world as it should.

Are you sure that there are no errors and you have node version 0.4? They added build-in cluster functionality since 0.5 if I recall it correctly.

deadrunk
  • 13,861
  • 4
  • 29
  • 29