mirror of
https://github.com/duanhf2012/origin.git
synced 2026-02-03 22:45:13 +08:00
调用本地service时,验证是否完成初始化
This commit is contained in:
@@ -36,6 +36,7 @@ type IModule interface {
|
||||
RunModule(module IModule) //手动运行Module
|
||||
InitModule(exit chan bool, pwaitGroup *sync.WaitGroup) error //手动初始化Module
|
||||
getBaseModule() *BaseModule //获取BaseModule指针
|
||||
IsInit() bool
|
||||
}
|
||||
|
||||
type BaseModule struct {
|
||||
@@ -52,6 +53,7 @@ type BaseModule struct {
|
||||
rwModuleLocker *sync.RWMutex
|
||||
ExitChan chan bool
|
||||
WaitGroup *sync.WaitGroup
|
||||
bInit bool
|
||||
}
|
||||
|
||||
func (slf *BaseModule) GetRoot() IModule {
|
||||
@@ -257,14 +259,19 @@ func (slf *BaseModule) getBaseModule() *BaseModule {
|
||||
return slf
|
||||
}
|
||||
|
||||
func (slf *BaseModule) IsInit() bool {
|
||||
return slf.bInit
|
||||
}
|
||||
|
||||
func (slf *BaseModule) RunModule(module IModule) {
|
||||
err := module.OnInit()
|
||||
if err != nil {
|
||||
GetLogger().Printf(LEVER_ERROR, "Start module %T id is %d is fail,reason:%v...", module, module.GetModuleId(), err)
|
||||
os.Exit(-1)
|
||||
} else {
|
||||
GetLogger().Printf(LEVER_INFO, "Start module %T ...", module)
|
||||
}
|
||||
GetLogger().Printf(LEVER_INFO, "Start module %T ...", module)
|
||||
|
||||
slf.bInit = true
|
||||
|
||||
//运行所有子模块
|
||||
timer := util.Timer{}
|
||||
|
||||
@@ -26,6 +26,7 @@ type IService interface {
|
||||
GetServiceId() int
|
||||
|
||||
GetStatus() int
|
||||
IsInit() bool
|
||||
}
|
||||
|
||||
type BaseService struct {
|
||||
|
||||
Reference in New Issue
Block a user