v1.18.x
barisusakli 9 years ago
parent d859163dea
commit 4eb8015017

@ -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.');

Loading…
Cancel
Save