Linked Questions

Popular Questions

Debugging Node.js processes with cluster.fork()

Asked by At

I've got some code that looks very much like the sample in the Cluster documentation at, to wit:

var cluster = require('cluster');
var server = require('./mycustomserver');
var numCPUs = require('os').cpus().length;

if (cluster.isMaster) {
  var i;
  // Master process
  for (i = 0; i < numCPUs; i++) {
  cluster.on('death', function (worker) {
    console.log('Worker ' + + ' died');
} else {
  // Worker process
  server.createServer({port: 80}, function(err, result) {
    if (err) {
      throw err;
    } else {
      console.log('Thread listening on port ' + result.port);

I've installed node-inspector and tried using both it and the Eclipse V8 plugin detailed at to debug my application, but it looks like I can't hook a debugger up to forked cluster instances to put breakpoints at the interesting server logic--I can only debug the part of the application that spawns the cluster processes. Does anybody know if I can in fact do such a thing, or am I going to have to refactor my application to use only a single thread when in debugging mode?

I'm a Node.js newbie, so I'm hoping there's something obvious I'm missing here.

Related Questions