diff --git a/src/install.js b/src/install.js index d84682ebc7..eb292e319c 100644 --- a/src/install.js +++ b/src/install.js @@ -42,6 +42,10 @@ var async = require('async'), }, { name: 'redis:password', description: 'Password of your Redis database' + }, { + name: "redis:database", + description: "Which database to use (0..n)", + 'default': 0 }, { name: 'bind_address', description: 'IP or Hostname to bind to', @@ -64,12 +68,14 @@ var async = require('async'), config.redis = { host: config['redis:host'], port: config['redis:port'], - password: config['redis:password'] + password: config['redis:password'], + database: config['redis:database'] }; delete config['redis:host']; delete config['redis:port']; delete config['redis:password']; - + delete config['redis:database']; + // Add hardcoded values config.bcrypt_rounds = 12; config.upload_path = '/public/uploads'; diff --git a/src/redis.js b/src/redis.js index c66c720788..b5852f92b3 100644 --- a/src/redis.js +++ b/src/redis.js @@ -17,6 +17,17 @@ RedisDB.exports.auth(nconf.get('redis:password')); } + if( (db = nconf.get('redis:database')) ){ + RedisDB.exports.select(db, function(error){ + if(error !== null){ + winston.err(error); + if (global.env !== 'production') { + throw new Error(error); + } + } + }); + } + RedisDB.exports.handle = function(error) { if (error !== null) { winston.err(error);