使用如下代码:
if (cluster.isMaster) {
// Fork启一个Worker 进程
for (var i = 0; i < numCPUs; i++) {
cluster.fork();
}
cluster.on('listening', (worker, address) => {
console.log('worker ' + worker.process.pid + ', listen: ' + address.address + ":" + address.port);
});
cluster.on('exit', (worker, code, signal) => {
console.log('worker ' + worker.process.pid + ' died');
//重启一个worker进程
cluster.fork();
});
} else {
// Worker 进程之间可以共享任何形式的TCP连接
// 也可以启动一个express的web服务
var server = app.listen(app.get('port'), function() {
debug('Express server listening on port ' + server.address().port);
});
}
系统报错:
isnode encountered an error when processing the request.
HRESULT: 0x2 HTTP status: 500 HTTP subStatus: 1002 HTTP reason: Internal Server Error
You are receiving this HTTP 200 response because system.webServer/iisnode/@devErrorsEnabled configuration setting is ‘true’.
In addition to the log of stdout and stderr of the node.exe process, consider using debugging and ETW traces to further diagnose the problem.
The last 64k of the output generated by the node.exe process to stderr is shown below:
Application has thrown an uncaught exception and is terminated: Error: write ENOTSUP at exports._errnoException (util.js:870:11) at ChildProcess.target._send (internal/child_process.js:611:20) at ChildProcess.target.send (internal/child_process.js:507:12) at sendHelper (cluster.js:723:8) at send (cluster.js:518:5) at cluster.js:493:7 at SharedHandle.options.process.on.process.on.SharedHandle.add (cluster.js:86:3) at queryServer (cluster.js:485:12) at Worker.onmessage (cluster.js:433:7) at ChildProcess.<anonymous> (cluster.js:737:8)
把 cluster 部份的代码注释掉后,一切正常。有没有同学碰到过,是如何解决这类问题的?