From 23ee7dd814c20f8abe6d2aa13d712976925451f6 Mon Sep 17 00:00:00 2001 From: Cloud Wu Date: Wed, 9 Aug 2017 14:34:09 +0800 Subject: [PATCH] use skynet.pcall in init, fix #704 --- service/service_cell.lua | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/service/service_cell.lua b/service/service_cell.lua index 3fa9ebbe..b24f147b 100644 --- a/service/service_cell.lua +++ b/service/service_cell.lua @@ -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