use skynet.pcall in init, fix #704

This commit is contained in:
Cloud Wu
2017-08-09 14:34:09 +08:00
parent 990bede9b2
commit 23ee7dd814

View File

@@ -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