mirror of
https://github.com/bunkerity/bunkerweb
synced 2026-05-24 09:28:37 +00:00
Add Redis check in API endpoints
This commit is contained in:
parent
93e4e63503
commit
638df130ec
2 changed files with 7 additions and 1 deletions
|
|
@ -38,6 +38,9 @@ end
|
|||
|
||||
function redis:api()
|
||||
if self.ctx.bw.uri == "/redis/ping" and self.ctx.bw.request_method == "POST" then
|
||||
if self.variables["USE_REDIS"] ~= "yes" then
|
||||
return self:ret(true, "redis is not enabled", HTTP_OK)
|
||||
end
|
||||
-- Check redis connection
|
||||
local ok, err = self.clusterstore:connect(true)
|
||||
if not ok then
|
||||
|
|
@ -59,6 +62,9 @@ function redis:api()
|
|||
return self:ret(true, "success", HTTP_OK)
|
||||
end
|
||||
if self.ctx.bw.uri == "/redis/stats" and self.ctx.bw.request_method == "GET" then
|
||||
if self.variables["USE_REDIS"] ~= "yes" then
|
||||
return self:ret(true, "redis is not enabled", HTTP_OK)
|
||||
end
|
||||
-- Connect to redis
|
||||
local ok, err = self.clusterstore:connect(true)
|
||||
if not ok then
|
||||
|
|
|
|||
|
|
@ -17,4 +17,4 @@ def redis(**kwargs):
|
|||
except:
|
||||
data = {"redis_nb_keys": 0}
|
||||
|
||||
return {**ping, **data}
|
||||
return ping | data
|
||||
|
|
|
|||
Loading…
Reference in a new issue