...
|
...
|
@@ -308,14 +308,28 @@ timer_handler(true,2,limit_ip_access_conf_to_worker) |
|
|
timer_handler(true,2,query_common_conf_to_worker)
|
|
|
|
|
|
|
|
|
local stream_ctx={}
|
|
|
function updownstream()
|
|
|
local keys=upstream_cache:get_keys()
|
|
|
|
|
|
for _,k in ipairs(keys) do
|
|
|
local value=upstream_cache:get(k)
|
|
|
local v=cjson.decode(value)
|
|
|
local ok,err=upstream.set_peer_down(v["upstream"],v["backup"],v["id"],v["value"])
|
|
|
if not ok then
|
|
|
ngx.log(ngx.ERR,"up or down stream err:",ngx.worker.id(),value,err)
|
|
|
if string.sub(k,1,1)=="d" then
|
|
|
|
|
|
local vKey="v" .. string.sub(k,2)
|
|
|
local version=upstream_cache:get(vKey)
|
|
|
|
|
|
local value=upstream_cache:get(k)
|
|
|
local v=cjson.decode(value)
|
|
|
|
|
|
if ( not stream_ctx[vKey] ) or stream_ctx[vKey] < version then
|
|
|
local ok,err=upstream.set_peer_down(v["upstream"],v["backup"],v["id"],v["value"])
|
|
|
if not ok then
|
|
|
ngx.log(ngx.ERR,"up or down stream err:",ngx.worker.id(),value,err)
|
|
|
else
|
|
|
stream_ctx[vKey]=version
|
|
|
end
|
|
|
end
|
|
|
|
|
|
end
|
|
|
end
|
|
|
end
|
...
|
...
|
|