This classic cluster example:
var cluster = require('cluster');
var http = require('http');
var numCPUs = require('os').cpus().length;
if (cluster.isMaster) {
// Fork workers.
for (var i = 0; i < numCPUs; i++) {
cluster.fork();
}
cluster.on('exit', function(worker, code, signal) {
console.log('worker ' + worker.process.pid + ' died');
});
} else {
// Workers can share any TCP connection
// In this case its a HTTP server
// Worker code omitted
}
Runs smoothly on my windows machine using the windows azure PowerShell and a simple node process, however when I deploy it to the azure emulator or a to a real worker role machine I get the following error:
spawn EBADF
at errnoException (child_process.js:837:11)
at ChildProcess.spawn (child_process.js:789:11)
at exports.spawn (child_process.js:614:9)
at exports.fork (child_process.js:443:10)
at new Worker (cluster.js:288:20)
at Cluster.cluster.fork (cluster.js:474:11)
at Object.<anonymous> (X:\workspaces\tp\deploy\local_package.csx\roles\zealot\approot\server.js:8:13)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
Anyone knows why this happens or how I can debug this problem ?
Thanks....
UPDATE: this problem seems to only occur in node engine >= 0.8.0
UPDATE2: opened an issue https://github.com/joyent/node/issues/3779