gpt4 book ai didi

javascript - 如何在 Windows 上运行 Node 集群?

转载 作者:IT老高 更新时间:2023-10-28 23:21:57 26 4
gpt4 key购买 nike

有人知道如何在 Windows 上运行 Node Cluster 吗?我在网上找不到任何文章,似乎无法解决这个问题:

events.js:160
throw er; // Unhandled 'error' event
^

Error: write ENOTSUP
at exports._errnoException (util.js:1007:11)
at ChildProcess.target._send (internal/child_process.js:634:20)
at ChildProcess.target.send (internal/child_process.js:521:19)
at sendHelper (cluster.js:751:15)
at send (cluster.js:534:12)
at cluster.js:509:7
at SharedHandle.add (cluster.js:99:3)
at queryServer (cluster.js:501:12)
at Worker.onmessage (cluster.js:449:7)
at ChildProcess.<anonymous> (cluster.js:765:8)

还有代码……

if (cluster.isMaster) {
for (let i = 0; i < numCPUs; i++) {
cluster.fork();
}
cluster.on('online', (worker) => {
console.log('Worker ' + worker.process.pid + ' is online');
});
cluster.on('exit', (worker, code, signal) => {
console.log(`Worker ${worker.process.pid} died with code ${code} and signal ${signal}`);
});
} else {
console.log('else part ');
openPort();
}

function openPort() {
let server = dgram.createSocket('udp4');
server.bind(port, host);
server.on('message', processMessage);
}

最佳答案

在 v0.11.14 中添加了对 UDP 集群的支持(适用于 Linux 和 OSX)。查看 file在 node.js master 上,上面写着“windows 目前不支持 dgram 集群”

关于javascript - 如何在 Windows 上运行 Node 集群?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39253637/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com