mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-25 04:33:05 +00:00
Merge pull request #555 from lipeiyuan/master
pass the inject code error to debug_console
This commit is contained in:
@@ -52,9 +52,9 @@ local function init(skynet, export)
|
|||||||
|
|
||||||
function dbgcmd.RUN(source, filename)
|
function dbgcmd.RUN(source, filename)
|
||||||
local inject = require "skynet.inject"
|
local inject = require "skynet.inject"
|
||||||
local output = inject(skynet, source, filename , export.dispatch, skynet.register_protocol)
|
local ok, output = inject(skynet, source, filename , export.dispatch, skynet.register_protocol)
|
||||||
collectgarbage "collect"
|
collectgarbage "collect"
|
||||||
skynet.ret(skynet.pack(table.concat(output, "\n")))
|
skynet.ret(skynet.pack(ok, table.concat(output, "\n")))
|
||||||
end
|
end
|
||||||
|
|
||||||
function dbgcmd.TERM(service)
|
function dbgcmd.TERM(service)
|
||||||
|
|||||||
@@ -54,12 +54,13 @@ return function(skynet, source, filename , ...)
|
|||||||
local env = setmetatable( { print = print , _U = u, _P = p}, { __index = _ENV })
|
local env = setmetatable( { print = print , _U = u, _P = p}, { __index = _ENV })
|
||||||
local func, err = load(source, filename, "bt", env)
|
local func, err = load(source, filename, "bt", env)
|
||||||
if not func then
|
if not func then
|
||||||
return { err }
|
return false, { err }
|
||||||
end
|
end
|
||||||
local ok, err = skynet.pcall(func)
|
local ok, err = skynet.pcall(func)
|
||||||
if not ok then
|
if not ok then
|
||||||
table.insert(output, err)
|
table.insert(output, err)
|
||||||
|
return false, output
|
||||||
end
|
end
|
||||||
|
|
||||||
return output
|
return true, output
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -242,7 +242,11 @@ function COMMAND.inject(address, filename)
|
|||||||
end
|
end
|
||||||
local source = f:read "*a"
|
local source = f:read "*a"
|
||||||
f:close()
|
f:close()
|
||||||
return skynet.call(address, "debug", "RUN", source, filename)
|
local ok, output = skynet.call(address, "debug", "RUN", source, filename)
|
||||||
|
if ok == false then
|
||||||
|
error(output)
|
||||||
|
end
|
||||||
|
return output
|
||||||
end
|
end
|
||||||
|
|
||||||
function COMMAND.task(address)
|
function COMMAND.task(address)
|
||||||
|
|||||||
Reference in New Issue
Block a user