mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-22 02:53:09 +00:00
cluster reload should reset old connection to update address:port
This commit is contained in:
@@ -5,14 +5,6 @@ local cluster = require "cluster.core"
|
||||
|
||||
local config_name = skynet.getenv "cluster"
|
||||
local node_address = {}
|
||||
|
||||
local function loadconfig()
|
||||
local f = assert(io.open(config_name))
|
||||
local source = f:read "*a"
|
||||
f:close()
|
||||
assert(load(source, "@"..config_name, "t", node_address))()
|
||||
end
|
||||
|
||||
local node_session = {}
|
||||
local command = {}
|
||||
|
||||
@@ -37,6 +29,24 @@ end
|
||||
|
||||
local node_channel = setmetatable({}, { __index = open_channel })
|
||||
|
||||
local function loadconfig()
|
||||
local f = assert(io.open(config_name))
|
||||
local source = f:read "*a"
|
||||
f:close()
|
||||
local tmp = {}
|
||||
assert(load(source, "@"..config_name, "t", tmp))()
|
||||
for name,address in pairs(tmp) do
|
||||
assert(type(address) == "string")
|
||||
if node_address[name] ~= address then
|
||||
-- address changed
|
||||
if rawget(node_channel, name) then
|
||||
node_channel[name] = nil -- reset connection
|
||||
end
|
||||
node_address[name] = address
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function command.reload()
|
||||
loadconfig()
|
||||
skynet.ret(skynet.pack(nil))
|
||||
|
||||
Reference in New Issue
Block a user