use skynet.pcall in init, fix
@@ -4,10 +4,16 @@ local service_name = (...)
local init = {}
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.start = function(f) f() end
local mainfunc = assert(load(code, service_name))
- mainfunc(...)
+ assert(skynet.pcall(mainfunc,...))
+ if start_func then
+ start_func()
+ end
skynet.ret()
end
