Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "3rd/jemalloc"]
path = 3rd/jemalloc
url = https://github.com/jemalloc/jemalloc.git
[submodule "3rd/lua-snapshot"]
path = 3rd/lua-snapshot
url = https://github.com/cloudwu/lua-snapshot.git
1 change: 1 addition & 0 deletions 3rd/lua-snapshot
Submodule lua-snapshot added at 5fdc88
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ LUA_CLIB_SKYNET = \
lua-mysqlaux.c \
lua-debugchannel.c \
lua-datasheet.c \
lua-snapshot.c \
\

SKYNET_SRC = skynet_main.c skynet_handle.c skynet_module.c skynet_mq.c \
Expand Down
21 changes: 21 additions & 0 deletions lualib/skynet/debug.lua
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,27 @@ local function init(skynet, export)
skynet.ret()
end

local old_snapshot
function dbgcmd.SNAPSHOT()
local snapshot = require "snapshot"
local construct_indentation = (require "skynet.snapshot_utils").construct_indentation
collectgarbage "collect"
local new_snapshot = snapshot()
if not old_snapshot then
old_snapshot = new_snapshot
return skynet.ret(skynet.pack({}))
end
local diff = {}
for k,v in pairs(new_snapshot) do
if not old_snapshot[k] then
diff[k] = v
end
end
old_snapshot = new_snapshot
local ret = construct_indentation(diff)
skynet.ret(skynet.pack(ret))
end

return dbgcmd
end -- function init_dbgcmd

Expand Down