mirror of
https://github.com/duanhf2012/origin.git
synced 2026-02-28 18:25:05 +08:00
修改模块初始化流程
This commit is contained in:
@@ -209,11 +209,19 @@ func (slf *BaseModule) AddModule(module IModule) uint32 {
|
|||||||
slf.mapModule[module.GetModuleId()] = module
|
slf.mapModule[module.GetModuleId()] = module
|
||||||
|
|
||||||
//运行模块
|
//运行模块
|
||||||
|
err := module.OnInit()
|
||||||
|
if err != nil {
|
||||||
|
GetLogger().Printf(LEVER_ERROR, "Init module %T id is %d is fail,reason:%v...", module, module.GetModuleId(), err)
|
||||||
|
os.Exit(-1)
|
||||||
|
}
|
||||||
|
module.getBaseModule().OnInit()
|
||||||
|
|
||||||
go module.RunModule(module)
|
go module.RunModule(module)
|
||||||
return module.GetModuleId()
|
return module.GetModuleId()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (slf *BaseModule) OnInit() error {
|
func (slf *BaseModule) OnInit() error {
|
||||||
|
slf.bInit = true
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -264,14 +272,12 @@ func (slf *BaseModule) IsInit() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (slf *BaseModule) RunModule(module IModule) {
|
func (slf *BaseModule) RunModule(module IModule) {
|
||||||
err := module.OnInit()
|
/*err := module.OnInit()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
GetLogger().Printf(LEVER_ERROR, "Start module %T id is %d is fail,reason:%v...", module, module.GetModuleId(), err)
|
GetLogger().Printf(LEVER_ERROR, "Start module %T id is %d is fail,reason:%v...", module, module.GetModuleId(), err)
|
||||||
os.Exit(-1)
|
os.Exit(-1)
|
||||||
}
|
}*/
|
||||||
GetLogger().Printf(LEVER_INFO, "Start module %T ...", module)
|
GetLogger().Printf(LEVER_INFO, "Start Run module %T ...", module)
|
||||||
|
|
||||||
slf.bInit = true
|
|
||||||
|
|
||||||
//运行所有子模块
|
//运行所有子模块
|
||||||
timer := util.Timer{}
|
timer := util.Timer{}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package service
|
package service
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type IServiceManager interface {
|
type IServiceManager interface {
|
||||||
@@ -56,6 +56,16 @@ func (slf *CServiceManager) Init(logger ILogger, exit chan bool, pwaitGroup *syn
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (slf *CServiceManager) Start() bool {
|
func (slf *CServiceManager) Start() bool {
|
||||||
|
|
||||||
|
for _, s := range slf.localserviceMap {
|
||||||
|
err := s.(IModule).OnInit()
|
||||||
|
if err != nil {
|
||||||
|
GetLogger().Printf(LEVER_ERROR, "Init module %T id is %d is fail,reason:%v...", s.(IModule), s.(IModule).GetModuleId(), err)
|
||||||
|
os.Exit(-1)
|
||||||
|
}
|
||||||
|
s.(IModule).getBaseModule().OnInit()
|
||||||
|
}
|
||||||
|
|
||||||
for _, s := range slf.localserviceMap {
|
for _, s := range slf.localserviceMap {
|
||||||
go (s.(IModule)).RunModule(s.(IModule))
|
go (s.(IModule)).RunModule(s.(IModule))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user