From 4ada09b93c02cecbc59e417b06cc54eddb2aa62f Mon Sep 17 00:00:00 2001 From: Cloud Wu Date: Fri, 6 May 2016 14:06:38 +0800 Subject: [PATCH] add pcall in launcher --- service/launcher.lua | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/service/launcher.lua b/service/launcher.lua index 82e7d4be..272a459a 100644 --- a/service/launcher.lua +++ b/service/launcher.lua @@ -24,7 +24,10 @@ end function command.STAT() local list = {} for k,v in pairs(services) do - local stat = skynet.call(k,"debug","STAT") + local ok, stat = pcall(skynet.call,k,"debug","STAT") + if not ok then + stat = string.format("ERROR (%s)",v) + end list[skynet.address(k)] = stat end return list @@ -41,8 +44,12 @@ end function command.MEM() local list = {} for k,v in pairs(services) do - local kb, bytes = skynet.call(k,"debug","MEM") - list[skynet.address(k)] = string.format("%.2f Kb (%s)",kb,v) + local ok, kb, bytes = pcall(skynet.call,k,"debug","MEM") + if not ok then + list[skynet.address(k)] = string.format("ERROR (%s)",v) + else + list[skynet.address(k)] = string.format("%.2f Kb (%s)",kb,v) + end end return list end