cluster sticky session

This commit is contained in:
barisusakli
2014-11-26 17:24:49 -05:00
parent 99e0a02b4c
commit d1fcb50c7d
2 changed files with 59 additions and 1 deletions

View File

@@ -124,7 +124,9 @@ if(nconf.get('ssl')) {
module.exports.listen = function(callback) {
var bind_address = ((nconf.get('bind_address') === "0.0.0.0" || !nconf.get('bind_address')) ? '0.0.0.0' : nconf.get('bind_address')) + ':' + port;
if (cluster.isWorker) {
port = 0;
}
server.listen(port, nconf.get('bind_address'), function(err) {
if (err) {
winston.info('NodeBB was unable to listen on: ' + bind_address);
@@ -144,4 +146,13 @@ if(nconf.get('ssl')) {
});
};
process.on('message', function(message, connection) {
if (!message || message.action !== 'sticky-session:connection') {
return;
}
server.emit('connection', connection);
process.send({action: 'sticky-session:accept', handleIndex: message.handleIndex});
});
}(WebServer));