diff --git a/loader.js b/loader.js index 7fce34006b..aaf9a03c19 100644 --- a/loader.js +++ b/loader.js @@ -141,15 +141,6 @@ Loader.addClusterEvents = function(callback) { case 'config:update': Loader.notifyWorkers(message); break; - case 'sticky-session:accept': - var _handle = handles[message.handleIndex]; - - if (_handle) { - _handle.close(); - - delete handles[message.handleIndex]; - } - break; } } }); @@ -229,6 +220,19 @@ function forkWorker(isPrimary) { worker.process.stdout.pipe(output); worker.process.stderr.pipe(output); } + + worker.on('message', function(message) { + if (!message || message.action !== 'sticky-session:accept') { + return; + } + var _handle = handles[message.handleIndex]; + + if (_handle) { + _handle.close(); + + delete handles[message.handleIndex]; + } + }); } function workerIndex(ip, numProcs) { diff --git a/src/webserver.js b/src/webserver.js index ddcd75ae1e..5cbe8cd225 100644 --- a/src/webserver.js +++ b/src/webserver.js @@ -151,8 +151,8 @@ if(nconf.get('ssl')) { return; } - server.emit('connection', connection); process.send({action: 'sticky-session:accept', handleIndex: message.handleIndex}); + server.emit('connection', connection); }); }(WebServer));