diff --git a/lualib/skynet/debug.lua b/lualib/skynet/debug.lua index 6e886f02..6f6186ee 100644 --- a/lualib/skynet/debug.lua +++ b/lualib/skynet/debug.lua @@ -69,6 +69,14 @@ function dbgcmd.SUPPORT(pname) return skynet.ret(skynet.pack(skynet.dispatch(pname) ~= nil)) end +function dbgcmd.PING() + return skynet.ret() +end + +function dbgcmd.LINK() + -- no return, raise error when exit +end + return dbgcmd end -- function init_dbgcmd diff --git a/service/debug_console.lua b/service/debug_console.lua index 92d99403..7b68a866 100644 --- a/service/debug_console.lua +++ b/service/debug_console.lua @@ -115,7 +115,7 @@ function COMMAND.help() help = "This help message", list = "List all the service", stat = "Dump all stats", - info = "Info address : get service infomation", + info = "info address : get service infomation", exit = "exit address : kill a lua service", kill = "kill address : kill service", mem = "mem : show memory status", @@ -133,6 +133,7 @@ function COMMAND.help() signal = "signal address sig", cmem = "Show C memory info", shrtbl = "Show shared short string table info", + ping = "ping address", } end @@ -283,3 +284,11 @@ function COMMAND.shrtbl() local n, total, longest, space = memory.ssinfo() return { n = n, total = total, longest = longest, space = space } end + +function COMMAND.ping(fd, address) + address = adjust_address(address) + local ti = skynet.now() + skynet.call(address, "debug", "PING") + ti = skynet.now() - ti + return tostring(ti) +end