check if worker exists

v1.18.x
barisusakli 10 years ago
parent cbb3ff26e9
commit 17d7916fe9

@ -193,12 +193,18 @@ Loader.start = function(callback) {
server = net.createServer(function(connection) {
// remove this once node 0.12.x ships, see https://github.com/elad/node-cluster-socket.io/issues/4
connection._handle.readStop();
handles[handleIndex] = connection._handle;
var workers = clusterWorkers();
var workers = clusterWorkers();
var worker = workers[workerIndex(connection.remoteAddress, numProcs)];
worker.send({action: 'sticky-session:connection', handleIndex: handleIndex}, connection);
handleIndex ++;
if (worker) {
handles[handleIndex] = connection._handle;
worker.send({action: 'sticky-session:connection', handleIndex: handleIndex}, connection);
handleIndex ++;
} else {
console.log('Cant find worker! Worker count : ' + workers.length);
}
}).listen(port);

Loading…
Cancel
Save