工作进程:
var http = require('http');
var port = Math.round((1 + Math.random()) * 1000);
http.createServer(function (req, res) {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('Hello World\n');
}).listen(port, '127.0.0.1');
console.log("port: ", port);
主进程:
var { fork } = require('child_process');
var cpus = require('os').cpus();
for (var i = 0; i < cpus.length; i++) {
fork('./process_worker.js');
}
修改时间 2022-02-28
声明:本站所有文章和图片,如无特殊说明,均为原创发布,转载请注明出处。