if(cluster.isMaster){
for (var i = 0; i < numCPUs; i++) {
var worker = cluster.fork();
worker.on('online', function() {
util.log('on line wid:' + worker.process.pid);
});
}
util.log('cluster.isMaster');
} else if (cluster.isWorker) {
var server = net.createServer(Option,function(socket){
socket.name = socket.remoteAddress + ":" + socket.remotePort;
clients.push(socket);
....
server.listen(settings.port,settings.host);
util.log('listen ' + settings.host + ':' + settings.port + ' pid:' + process.pid);
}
> node app.js
cluster.isMaster
on line wid:5048
on line wid:5048
on line wid:5048
listen 192.168.1.104:1377 pid:6540
listen 192.168.1.104:1377 pid:1972
listen 192.168.1.104:1377 pid:3932
on line wid:5048
listen 192.168.1.104:1377 pid:5048
不管我客户端连接多大, 客户端连接之后,提示如下: 工作进程都是: listen 192.168.1.104:1377 pid:5048 为什么不轮询工作进程,老是5048???
7 回复