mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-23 19:43:09 +00:00
Update to lua 5.4 (#1174)
* update to lua 5.4.0-rc1 * remove LUA_ERRGCMM * use age bits for shared * remove unused lbitlib.c * use luaV_fastget * fix #1174 * suspend函数tailcall优化 * 防止没有session导致未调用suspend * luaH_setint check shared (#1184) * set LUA_GCGEN by default * fix #1174 (#1186) checkshared in sweeplist * update to lua 5.4 rc2 * update to lua 5.4 rc4 * move skynet.profile into snlua * Use lua_sethook to interrupt tight loops * remove lua_checksig * critical condition for signals * update to lua 5.4 released * lua 5.4 bugfix * update lua bugfix * fix lua_sharestring (#1224) * update lua * update lua 5.4 * update README * add skynet.select * add test * test error & discard * yield session * request error has no error message * add timeout to skynet.select * bugfix * for lua 5.4 * new version * bugfix * bugfix * use if instead of while * make local * yield in select for * update lua 5.4.1 * change lua version (#1245) Co-authored-by: xiaojin <xiaojin@onemt.com.cn> * update lua version number Co-authored-by: hong <hongling0@gmail.com> Co-authored-by: hong <hongling-0@qq.com> Co-authored-by: 风---自由 <996442717qqcom@gmail.com> Co-authored-by: xiaojin <xiaojin@onemt.com.cn>
This commit is contained in:
@@ -22,18 +22,35 @@ function command.LIST()
|
||||
return list
|
||||
end
|
||||
|
||||
function command.STAT()
|
||||
local function list_srv(ti, fmt_func, ...)
|
||||
local list = {}
|
||||
for k,v in pairs(services) do
|
||||
local ok, stat = pcall(skynet.call,k,"debug","STAT")
|
||||
if not ok then
|
||||
stat = string.format("ERROR (%s)",v)
|
||||
local sessions = {}
|
||||
local req = skynet.request()
|
||||
for addr in pairs(services) do
|
||||
local r = { addr, "debug", ... }
|
||||
req:add(r)
|
||||
sessions[r] = addr
|
||||
end
|
||||
for resp, req in req:select(ti) do
|
||||
local stat = resp[1]
|
||||
local addr = req[1]
|
||||
if resp.ok then
|
||||
list[skynet.address(addr)] = fmt_func(stat, addr)
|
||||
else
|
||||
list[skynet.address(addr)] = fmt_func("ERROR", addr)
|
||||
end
|
||||
list[skynet.address(k)] = stat
|
||||
sessions[req] = nil
|
||||
end
|
||||
for session, addr in pairs(sessions) do
|
||||
list[skynet.address(addr)] = fmt_func("TIMEOUT", addr)
|
||||
end
|
||||
return list
|
||||
end
|
||||
|
||||
function command.STAT(addr, ti)
|
||||
return list_srv(ti, function(v) return v end, "STAT")
|
||||
end
|
||||
|
||||
function command.KILL(_, handle)
|
||||
handle = handle_to_address(handle)
|
||||
skynet.kill(handle)
|
||||
@@ -42,24 +59,22 @@ function command.KILL(_, handle)
|
||||
return ret
|
||||
end
|
||||
|
||||
function command.MEM()
|
||||
local list = {}
|
||||
for k,v in pairs(services) do
|
||||
local ok, kb = pcall(skynet.call,k,"debug","MEM")
|
||||
if not ok then
|
||||
list[skynet.address(k)] = string.format("ERROR (%s)",v)
|
||||
function command.MEM(addr, ti)
|
||||
return list_srv(ti, function(kb, addr)
|
||||
local v = services[addr]
|
||||
if kb == "TIMEOUT" then
|
||||
return string.format("TIMEOUT (%s)",v)
|
||||
else
|
||||
list[skynet.address(k)] = string.format("%.2f Kb (%s)",kb,v)
|
||||
return string.format("%.2f Kb (%s)",kb,v)
|
||||
end
|
||||
end
|
||||
return list
|
||||
end, "MEM")
|
||||
end
|
||||
|
||||
function command.GC()
|
||||
function command.GC(addr, ti)
|
||||
for k,v in pairs(services) do
|
||||
skynet.send(k,"debug","GC")
|
||||
end
|
||||
return command.MEM()
|
||||
return command.MEM(ti)
|
||||
end
|
||||
|
||||
function command.REMOVE(_, handle, kill)
|
||||
|
||||
Reference in New Issue
Block a user