Add redis version check so errors are thrown if you use too old of a redis version

This commit is contained in:
Matt 2014-05-12 11:15:17 -06:00
parent 2eef180751
commit ac7d7780fd
2 changed files with 27 additions and 1 deletions

View File

@ -170,7 +170,7 @@ Inside the `config_example.json` file, ensure the default configuration will wor
Explanation for each field:
````javascript
{
/* Specifies the level of log output verbosity. Anything more severy than the level specified
/* Specifies the level of log output verbosity. Anything more severe than the level specified
will also be logged. */
"logLevel": "debug", //or "warning", "error"

View File

@ -14,6 +14,7 @@ value: a hash with..
*/
module.exports = function(logger, poolConfig){
var redisConfig = poolConfig.redis;
@ -38,6 +39,31 @@ module.exports = function(logger, poolConfig){
logger.error(logSystem, logComponent, logSubCat, 'Connection to redis database as been ended');
});
connection.info(function(error, response){
if (error){
logger.error(logSystem, logComponent, logSubCat, 'Redis version check failed');
return;
}
var parts = response.split('\r\n');
var version;
var versionString;
for (var i = 0; i < parts.length; i++){
if (parts[i].indexOf(':') !== -1){
var valParts = parts[i].split(':');
if (valParts[0] === 'redis_version'){
versionString = valParts[1];
version = parseFloat(versionString);
break;
}
}
}
if (!version){
logger.error(logSystem, logComponent, logSubCat, 'Could not detect redis version - but be super old or broken');
}
else if (version < 2.6){
logger.error(logSystem, logComponent, logSubCat, "You're using redis version " + versionString + " the minimum required version is 2.6. Follow the damn usage instructions...");
}
});
this.handleShare = function(isValidShare, isValidBlock, shareData){