From f6fa7d281aab62b1ca23a25d8cfc36785a562797 Mon Sep 17 00:00:00 2001 From: ivrrecht Date: Tue, 1 Dec 2015 15:38:19 +0100 Subject: [PATCH] added redis socket support In order to enable socket support I added another command line argument: `--sock` which can be true or false. If set to true the script will try to connect via sockets to the redis host provided via the `--redis` flag. In that case the port will be omitted. --- config.js | 1 + lib/data/redis.js | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/config.js b/config.js index 3789ec3..ff5d9d6 100644 --- a/config.js +++ b/config.js @@ -22,6 +22,7 @@ exports.googleanalytics = { var redis_conf = argv.redis || '127.0.0.1:6379'; exports.database = { + sock: argv['sock'] || false, type: 'redis', prefix: '#scrumblr#', host: redis_conf.split(':')[0] || '127.0.0.1', diff --git a/lib/data/redis.js b/lib/data/redis.js index baf451e..00d61d1 100644 --- a/lib/data/redis.js +++ b/lib/data/redis.js @@ -16,8 +16,13 @@ var REDIS_PREFIX = '#scrumblr#'; var db = function(callback) { - console.log('Opening redis connection to ' + conf.host + ':' + conf.port); - redisClient = redis.createClient(conf.port, conf.host, {}); + if (conf.sock) { + console.log('Opening redis connection to socket ' + conf.host); + redisClient = redis.createClient(conf.host); + } else { + console.log('Opening redis connection to ' + conf.host + ':' + conf.port); + redisClient = redis.createClient(conf.port, conf.host, {}); + } redisClient.on("connect", function (err) { callback(); });