这个经典的集群示例:
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
}
使用 windows azure PowerShell 和简单的节点进程在我的 windows 机器上顺利运行,但是当我将它部署到 azure 模拟器或真正的工作角色机器时,我收到以下错误:
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)
任何人都知道为什么会发生这种情况或我如何调试这个问题?
谢谢....
更新:这个问题似乎只发生在节点引擎> = 0.8.0
UPDATE2:打开一个问题https://github.com/joyent/node/issues/3779