Allow single-host clusters to not send pubsub and socket.io messages through the database. (#6659)

* Allow single-host clusters to not send pubsub and socket.io messages through the database.

* Fix lint errors.
This commit is contained in:
Ben Lubar
2018-07-23 11:21:36 -05:00
committed by Barış Soner Uşaklı
parent 148fc96a3a
commit c1e98eefa7
4 changed files with 32 additions and 2 deletions

View File

@@ -27,7 +27,13 @@ Sockets.init = function (server) {
path: nconf.get('relative_path') + '/socket.io',
});
io.adapter(nconf.get('redis') ? require('../database/redis').socketAdapter() : db.socketAdapter());
if (nconf.get('singleHostCluster')) {
io.adapter(require('socket.io-adapter-cluster')());
} else if (nconf.get('redis')) {
io.adapter(require('../database/redis').socketAdapter());
} else {
io.adapter(db.socketAdapter());
}
io.use(socketioWildcard);
io.use(authorize);