mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-22 02:53:09 +00:00
use skynet.pcall in init, fix #704
This commit is contained in:
@@ -4,10 +4,16 @@ local service_name = (...)
|
|||||||
local init = {}
|
local init = {}
|
||||||
|
|
||||||
function init.init(code, ...)
|
function init.init(code, ...)
|
||||||
|
local start_func
|
||||||
|
skynet.start = function(f)
|
||||||
|
start_func = f
|
||||||
|
end
|
||||||
skynet.dispatch("lua", function() error("No dispatch function") end)
|
skynet.dispatch("lua", function() error("No dispatch function") end)
|
||||||
skynet.start = function(f) f() end
|
|
||||||
local mainfunc = assert(load(code, service_name))
|
local mainfunc = assert(load(code, service_name))
|
||||||
mainfunc(...)
|
assert(skynet.pcall(mainfunc,...))
|
||||||
|
if start_func then
|
||||||
|
start_func()
|
||||||
|
end
|
||||||
skynet.ret()
|
skynet.ret()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user