add more info when service init blocked

This commit is contained in:
Cloud Wu
2018-09-13 18:27:05 +08:00
parent 43d02ac456
commit 89e7a06deb
3 changed files with 67 additions and 15 deletions

View File

@@ -42,12 +42,17 @@ local function waitfor(name , func, ...)
assert(type(s) == "table")
if not s.launch and func then
s.launch = true
local session, source = skynet.context()
if s.launch == nil and func then
s.launch = {
session = session,
source = source,
co = co,
}
return request(name, func, ...)
end
local session, source = skynet.context()
table.insert(s, {
co = co,
session = session,
@@ -96,9 +101,20 @@ local function list_service()
if type(v) == "string" then
v = "Error: " .. v
elseif type(v) == "table" then
local querying = { "Querying:" }
for _, detail in ipairs(v) do
table.insert(querying, skynet.address(detail.source) .. " " .. tostring(skynet.call(detail.source, "debug", "TASK", detail.session)))
local querying = {}
if v.launch then
local session = skynet.task(v.launch.co)
local launching_address = skynet.call(".launcher", "lua", "QUERY", session)
table.insert(querying, "Init as " .. skynet.address(launching_address))
table.insert(querying, tostring(skynet.call(launching_address, "debug", "TASK", "init")))
table.insert(querying, "Launching from " .. skynet.address(v.launch.source))
table.insert(querying, tostring(skynet.call(v.launch.source, "debug", "TASK", v.launch.session)))
end
if #v > 0 then
table.insert(querying , "Querying:" )
for _, detail in ipairs(v) do
table.insert(querying, skynet.address(detail.source) .. " " .. tostring(skynet.call(detail.source, "debug", "TASK", detail.session)))
end
end
v = table.concat(querying, "\n")
else