diff options
author | Alexander Moisseev <moiseev@mezonplus.ru> | 2018-03-10 19:09:08 +0300 |
---|---|---|
committer | Alexander Moisseev <moiseev@mezonplus.ru> | 2018-03-10 19:09:08 +0300 |
commit | 24f312aae440cf8a99df443a38235b6f2cdb05ed (patch) | |
tree | 98ca65e06ccae5c91cdd89bb418f4324076c51d5 /lualib | |
parent | 837393b130a160235b211f0ab0530bef97167476 (diff) | |
download | rspamd-24f312aae440cf8a99df443a38235b6f2cdb05ed.tar.gz rspamd-24f312aae440cf8a99df443a38235b6f2cdb05ed.zip |
[Minor] Abort classifier checks if failed to connect to Redis
Diffstat (limited to 'lualib')
-rw-r--r-- | lualib/rspamadm/configwizard.lua | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/lualib/rspamadm/configwizard.lua b/lualib/rspamadm/configwizard.lua index d42f4c3f3..efe91f6eb 100644 --- a/lualib/rspamadm/configwizard.lua +++ b/lualib/rspamadm/configwizard.lua @@ -357,8 +357,7 @@ local function check_redis_classifier(cls, changes) end end - local function get_version() - local _,conn = lua_redis.redis_connect_sync(parsed_redis, true) + local function get_version(conn) -- We still need to check versions local lua_script = [[ local ver = 0 @@ -376,8 +375,7 @@ return ver return tonumber(ver) end - local function check_expire() - local _,conn = lua_redis.redis_connect_sync(parsed_redis, true) + local function check_expire(conn) -- We still need to check versions local lua_script = [[ local ttl = 0 @@ -397,8 +395,14 @@ return ttl return tonumber(ttl) end + local res,conn = lua_redis.redis_connect_sync(parsed_redis, true) + if not res then + printf("Cannot connect to Redis server") + return false + end + if not cls.new_schema then - local ver = get_version() + local ver = get_version(conn) if ver ~= 2 then printf("You are using an old schema for %s/%s", symbol_ham, symbol_spam) @@ -412,14 +416,14 @@ return ttl new_schema = true, } - local expire = check_expire() + local expire = check_expire(conn) if expire then changes.l['classifier-bayes.conf'].expire = expire end end end else - local ver = get_version() + local ver = get_version(conn) if ver ~= 2 then printf("You have configured new schema for %s/%s but your DB has old data", symbol_spam, symbol_ham) |