mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-24 12:20:41 +00:00
set node = false when node is down, see #803
This commit is contained in:
@@ -33,19 +33,25 @@ local function open_channel(t, key)
|
||||
ct.namequery = co
|
||||
skynet.error("Wating for cluster node [".. key.."]")
|
||||
skynet.wait(co)
|
||||
address = assert(node_address[key])
|
||||
address = node_address[key]
|
||||
assert(address ~= nil)
|
||||
end
|
||||
local host, port = string.match(address, "([^:]+):(.*)$")
|
||||
local c = sc.channel {
|
||||
host = host,
|
||||
port = tonumber(port),
|
||||
response = read_response,
|
||||
nodelay = true,
|
||||
}
|
||||
local succ, err = pcall(c.connect, c, true)
|
||||
if succ then
|
||||
t[key] = c
|
||||
ct.channel = c
|
||||
local succ, err, c
|
||||
if address then
|
||||
local host, port = string.match(address, "([^:]+):(.*)$")
|
||||
c = sc.channel {
|
||||
host = host,
|
||||
port = tonumber(port),
|
||||
response = read_response,
|
||||
nodelay = true,
|
||||
}
|
||||
succ, err = pcall(c.connect, c, true)
|
||||
if succ then
|
||||
t[key] = c
|
||||
ct.channel = c
|
||||
end
|
||||
else
|
||||
err = "cluster node [" .. key .. "] is down."
|
||||
end
|
||||
connecting[key] = nil
|
||||
for _, co in ipairs(ct) do
|
||||
@@ -68,7 +74,7 @@ local function loadconfig(tmp)
|
||||
end
|
||||
end
|
||||
for name,address in pairs(tmp) do
|
||||
assert(type(address) == "string")
|
||||
assert(address == false or type(address) == "string")
|
||||
if node_address[name] ~= address then
|
||||
-- address changed
|
||||
if rawget(node_channel, name) then
|
||||
@@ -92,7 +98,8 @@ end
|
||||
function command.listen(source, addr, port)
|
||||
local gate = skynet.newservice("gate")
|
||||
if port == nil then
|
||||
addr, port = string.match(node_address[addr], "([^:]+):(.*)$")
|
||||
local address = assert(node_address[addr], addr .. " is down")
|
||||
addr, port = string.match(address, "([^:]+):(.*)$")
|
||||
end
|
||||
skynet.call(gate, "lua", "open", { address = addr, port = port })
|
||||
skynet.ret(skynet.pack(nil))
|
||||
|
||||
Reference in New Issue
Block a user