mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-22 02:53:09 +00:00
debug console inject cmd support args
This commit is contained in:
@@ -50,9 +50,10 @@ local function init(skynet, export)
|
||||
skynet.exit()
|
||||
end
|
||||
|
||||
function dbgcmd.RUN(source, filename)
|
||||
function dbgcmd.RUN(source, filename, ...)
|
||||
local inject = require "skynet.inject"
|
||||
local ok, output = inject(skynet, source, filename , export.dispatch, skynet.register_protocol)
|
||||
local args = table.pack(...)
|
||||
local ok, output = inject(skynet, source, filename, args, export.dispatch, skynet.register_protocol)
|
||||
collectgarbage "collect"
|
||||
skynet.ret(skynet.pack(ok, table.concat(output, "\n")))
|
||||
end
|
||||
|
||||
@@ -18,7 +18,7 @@ local function getupvaluetable(u, func, unique)
|
||||
end
|
||||
end
|
||||
|
||||
return function(skynet, source, filename , ...)
|
||||
return function(skynet, source, filename, args, ...)
|
||||
if filename then
|
||||
filename = "@" .. filename
|
||||
else
|
||||
@@ -56,7 +56,7 @@ return function(skynet, source, filename , ...)
|
||||
if not func then
|
||||
return false, { err }
|
||||
end
|
||||
local ok, err = skynet.pcall(func)
|
||||
local ok, err = skynet.pcall(func, table.unpack(args, 1, args.n))
|
||||
if not ok then
|
||||
table.insert(output, err)
|
||||
return false, output
|
||||
|
||||
@@ -237,7 +237,7 @@ function COMMAND.exit(address)
|
||||
skynet.send(adjust_address(address), "debug", "EXIT")
|
||||
end
|
||||
|
||||
function COMMAND.inject(address, filename)
|
||||
function COMMAND.inject(address, filename, ...)
|
||||
address = adjust_address(address)
|
||||
local f = io.open(filename, "rb")
|
||||
if not f then
|
||||
@@ -245,7 +245,7 @@ function COMMAND.inject(address, filename)
|
||||
end
|
||||
local source = f:read "*a"
|
||||
f:close()
|
||||
local ok, output = skynet.call(address, "debug", "RUN", source, filename)
|
||||
local ok, output = skynet.call(address, "debug", "RUN", source, filename, ...)
|
||||
if ok == false then
|
||||
error(output)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user