You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.4 KiB
Lua

-- 服务处理模版
local fsm = require "zeus.fsm"
local Template = class("Template"):include(singleton)
function Template:initialize()
self._cmds = {} -- 已注册的命令
self._exceptions = {} -- 已注册异常处理
self._updaters = {} -- 定时器
self._newday = { -- newday只允许注册一次且不可删除
curDay = os.date("%d", os.time()), -- 当前天
handle = nil, -- newday updater的句柄
}
self._fsm = fsm.create({
initial = "none",
events = {{
name = "initial",
from = "none",
to = "initial",
}, {
name = "running",
from = "initial",
to = "running",
}, {
name = "stop",
from = "running",
to = "stop",
}, {
name = "exit",
from = "stop",
to = "exit",
}},
callbacks = {
on_initial = handler("_on_initial", self),
on_running = handler("_on_running", self),
on_stop = handler("_on_stop", self),
on_exit = handler("_on_exit", self),
},
})
end
function Template:get_fsm()
return self._fsm
end
function Template:_on_initial()
end
function Template:_on_running()
end
function Template:_on_stop()
end
function Template:_on_exit()
end
function Template:reg_cmd()
end
return Template