From 809e6c3a89d87e99c863a65b32cb285b764fe15a Mon Sep 17 00:00:00 2001 From: Cloud Wu Date: Wed, 13 Aug 2014 19:37:26 +0800 Subject: [PATCH] add debug command: exit --- HISTORY.md | 2 ++ lualib/skynet/debug.lua | 6 +++++- service/debug_console.lua | 1 + service/launcher.lua | 5 +++++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/HISTORY.md b/HISTORY.md index 7d140bd0..8f1a5ac2 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -7,8 +7,10 @@ Dev version * Don't check imported function in snax.hotfix * snax service add change SERVICE_PATH and add it to package.path * skynet.redirect support string address +* bugfix: skynet.harbor.link may block * add skynet.harbor.queryname to query globalname * add cluster.proxy +* add DEBUG command exit (send a message to lua service by DEBUG) v0.5.2 (2014-8-11) ----------- diff --git a/lualib/skynet/debug.lua b/lualib/skynet/debug.lua index c8f51f0b..7e7ffa78 100644 --- a/lualib/skynet/debug.lua +++ b/lualib/skynet/debug.lua @@ -39,6 +39,10 @@ function dbgcmd.INFO() end end +function dbgcmd.EXIT() + skynet.exit() +end + local function _debug_dispatch(session, address, cmd, ...) local f = dbgcmd[cmd] assert(f, cmd) @@ -53,4 +57,4 @@ skynet.register_protocol { dispatch = _debug_dispatch, } -end \ No newline at end of file +end diff --git a/service/debug_console.lua b/service/debug_console.lua index aa552ceb..22cb7274 100644 --- a/service/debug_console.lua +++ b/service/debug_console.lua @@ -106,6 +106,7 @@ function COMMAND.help() list = "List all the service", stat = "Dump all stats", info = "Info address : get service infomation", + exit = "exit address : kill a lua service", kill = "kill address : kill service", mem = "mem : show memory status", gc = "gc : force every lua service do garbage collect", diff --git a/service/launcher.lua b/service/launcher.lua index 9cb194b4..58ae5f11 100644 --- a/service/launcher.lua +++ b/service/launcher.lua @@ -56,6 +56,11 @@ function command.KILL(_, handle) return ret end +function command.EXIT(_, handle) + handle = handle_to_address(handle) + skynet.send(handle, "debug", "EXIT") +end + function command.MEM() local list = {} for k,v in pairs(services) do