Blame view

publish/skynet/service/dbg.lua 808 Bytes
4d6f285d   zhouhaihai   增加发布功能
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
  local skynet = require "skynet"
  
  local cmd = { ... }
  
  local function format_table(t)
  	local index = {}
  	for k in pairs(t) do
  		table.insert(index, k)
  	end
  	table.sort(index)
  	local result = {}
  	for _,v in ipairs(index) do
  		table.insert(result, string.format("%s:%s",v,tostring(t[v])))
  	end
  	return table.concat(result,"\t")
  end
  
  local function dump_line(key, value)
  	if type(value) == "table" then
  		print(key, format_table(value))
  	else
  		print(key,tostring(value))
  	end
  end
  
  local function dump_list(list)
  	local index = {}
  	for k in pairs(list) do
  		table.insert(index, k)
  	end
  	table.sort(index)
  	for _,v in ipairs(index) do
  		dump_line(v, list[v])
  	end
  end
  
  skynet.start(function()
  	local list = skynet.call(".launcher","lua", table.unpack(cmd))
  	if list then
  		dump_list(list)
  	end
  	skynet.exit()
  end)