mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-17 11:11:04 +01:00
closes #5069
This commit is contained in:
@@ -81,7 +81,7 @@
|
||||
"sitemap": "^1.4.0",
|
||||
"socket.io": "^1.4.8",
|
||||
"socket.io-client": "^1.4.0",
|
||||
"socket.io-redis": "^1.0.0",
|
||||
"socket.io-redis": "1.1.1",
|
||||
"socketio-wildcard": "~0.3.0",
|
||||
"string": "^3.0.0",
|
||||
"templates.js": "0.3.4",
|
||||
|
||||
@@ -65,15 +65,18 @@
|
||||
};
|
||||
|
||||
module.connect = function(options) {
|
||||
var redis_socket_or_host = nconf.get('redis:host'),
|
||||
cxn, dbIdx;
|
||||
|
||||
options = options || {};
|
||||
var redis_socket_or_host = nconf.get('redis:host');
|
||||
var cxn;
|
||||
|
||||
if (!redis) {
|
||||
redis = require('redis');
|
||||
}
|
||||
|
||||
options = options || {};
|
||||
if (nconf.get('redis:password')) {
|
||||
options.auth_pass = nconf.get('redis:password');
|
||||
}
|
||||
|
||||
if (redis_socket_or_host && redis_socket_or_host.indexOf('/') >= 0) {
|
||||
/* If redis.host contains a path name character, use the unix dom sock connection. ie, /tmp/redis.sock */
|
||||
cxn = redis.createClient(nconf.get('redis:host'), options);
|
||||
@@ -91,7 +94,7 @@
|
||||
cxn.auth(nconf.get('redis:password'));
|
||||
}
|
||||
|
||||
dbIdx = parseInt(nconf.get('redis:database'), 10);
|
||||
var dbIdx = parseInt(nconf.get('redis:database'), 10);
|
||||
if (dbIdx) {
|
||||
cxn.select(dbIdx, function(error) {
|
||||
if(error) {
|
||||
|
||||
@@ -177,9 +177,8 @@ var ratelimit = require('../middleware/ratelimit');
|
||||
if (nconf.get('redis')) {
|
||||
var redisAdapter = require('socket.io-redis');
|
||||
var redis = require('../database/redis');
|
||||
var pub = redis.connect({return_buffers: true});
|
||||
var pub = redis.connect();
|
||||
var sub = redis.connect({return_buffers: true});
|
||||
|
||||
io.adapter(redisAdapter({pubClient: pub, subClient: sub}));
|
||||
} else if (nconf.get('isCluster') === 'true') {
|
||||
winston.warn('[socket.io] Clustering detected, you are advised to configure Redis as a websocket store.');
|
||||
|
||||
Reference in New Issue
Block a user