这个经典集群示例:
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)
任何人都知道为什么会发生这种情况或我如何调试此问题?
谢谢....
更新:此问题似乎只发生在节点引擎&gt; = 0.8.0
UPDATE2:打开了问题https://github.com/joyent/node/issues/3779
答案 0 :(得分:0)
相信这是在节点0.8.7中修复的