mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-06 22:15:48 +01:00
Fix single-host-cluster socket.io (#6802)
It was silently dropping every message because every node thought it was the master node.
This commit is contained in:
committed by
Barış Soner Uşaklı
parent
f95308bf33
commit
cf4ea94e6d
@@ -28,9 +28,7 @@ Sockets.init = function (server) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (nconf.get('singleHostCluster')) {
|
if (nconf.get('singleHostCluster')) {
|
||||||
io.adapter(require('socket.io-adapter-cluster')({
|
io.adapter(require('./single-host-cluster'));
|
||||||
client: require('./single-host-cluster'),
|
|
||||||
}));
|
|
||||||
} else if (nconf.get('redis')) {
|
} else if (nconf.get('redis')) {
|
||||||
io.adapter(require('../database/redis').socketAdapter());
|
io.adapter(require('../database/redis').socketAdapter());
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -51,4 +51,17 @@ process.on('message', function (message) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = Client;
|
var adapter = require('socket.io-adapter-cluster')({
|
||||||
|
client: Client,
|
||||||
|
});
|
||||||
|
// Otherwise, every node thinks it is the master node and ignores messages
|
||||||
|
// because they are from "itself".
|
||||||
|
Object.defineProperty(adapter.prototype, 'id', {
|
||||||
|
get: function () {
|
||||||
|
return process.pid;
|
||||||
|
},
|
||||||
|
set: function (id) {
|
||||||
|
// ignore
|
||||||
|
},
|
||||||
|
});
|
||||||
|
module.exports = adapter;
|
||||||
|
|||||||
Reference in New Issue
Block a user