mirror of
https://github.com/duanhf2012/origin.git
synced 2026-02-18 18:34:45 +08:00
修改module模块使用
This commit is contained in:
@@ -15,20 +15,16 @@ type GlobalModule struct {
|
||||
|
||||
var g_module GlobalModule
|
||||
|
||||
func AddModule(module service.IModule) bool {
|
||||
if module.GetModuleType() == 0 {
|
||||
return false
|
||||
}
|
||||
|
||||
func AddModule(module service.IModule) uint32 {
|
||||
return g_module.AddModule(module)
|
||||
}
|
||||
|
||||
func GetModuleByType(moduleType uint32) service.IModule {
|
||||
return g_module.GetModuleByType(moduleType)
|
||||
func GetModuleById(moduleId uint32) service.IModule {
|
||||
return g_module.GetModuleById(moduleId)
|
||||
}
|
||||
|
||||
func GetLog(logmodule uint32) sysmodule.ILogger {
|
||||
module := g_module.GetModuleByType(logmodule)
|
||||
module := g_module.GetModuleById(logmodule)
|
||||
if nil == module {
|
||||
return nil
|
||||
}
|
||||
@@ -36,10 +32,10 @@ func GetLog(logmodule uint32) sysmodule.ILogger {
|
||||
return module.(sysmodule.ILogger)
|
||||
}
|
||||
|
||||
func InitGlobalModule() {
|
||||
g_module.InitModule(&g_module)
|
||||
func InitGlobalModule(exit chan bool, pwaitGroup *sync.WaitGroup) {
|
||||
g_module.InitModule(exit, pwaitGroup)
|
||||
}
|
||||
|
||||
func RunGlobalModule(exit chan bool, pwaitGroup *sync.WaitGroup) {
|
||||
g_module.RunModule(&g_module, exit, pwaitGroup)
|
||||
func RunGlobalModule() {
|
||||
g_module.RunModule(&g_module)
|
||||
}
|
||||
|
||||
@@ -29,14 +29,15 @@ type COriginNode struct {
|
||||
}
|
||||
|
||||
func (s *COriginNode) Init() {
|
||||
//初始化全局模块
|
||||
InitGlobalModule()
|
||||
service.InitLog()
|
||||
imodule := g_module.GetModuleByType(sysmodule.SYS_LOG)
|
||||
service.InstanceServiceMgr().Init(imodule.(service.ILogger))
|
||||
//s.exit = make(chan bool)
|
||||
//s.waitGroup = &sync.WaitGroup{}
|
||||
|
||||
//初始化全局模块
|
||||
|
||||
service.InitLog()
|
||||
imodule := g_module.GetModuleById(sysmodule.SYS_LOG)
|
||||
service.InstanceServiceMgr().Init(imodule.(service.ILogger), s.exit, s.waitGroup)
|
||||
|
||||
s.exit = make(chan bool)
|
||||
s.waitGroup = &sync.WaitGroup{}
|
||||
s.sigs = make(chan os.Signal, 1)
|
||||
signal.Notify(s.sigs, syscall.SIGINT, syscall.SIGTERM)
|
||||
}
|
||||
@@ -79,8 +80,8 @@ func (s *COriginNode) Start() {
|
||||
}
|
||||
|
||||
cluster.InstanceClusterMgr().Start()
|
||||
RunGlobalModule(s.exit, s.waitGroup)
|
||||
service.InstanceServiceMgr().Start(s.exit, s.waitGroup)
|
||||
RunGlobalModule()
|
||||
service.InstanceServiceMgr().Start()
|
||||
|
||||
select {
|
||||
case <-s.sigs:
|
||||
@@ -96,9 +97,13 @@ func (s *COriginNode) Stop() {
|
||||
}
|
||||
|
||||
func NewOrginNode() *COriginNode {
|
||||
node := new(COriginNode)
|
||||
node.exit = make(chan bool)
|
||||
node.waitGroup = &sync.WaitGroup{}
|
||||
InitGlobalModule(node.exit, node.waitGroup)
|
||||
var syslogmodule sysmodule.LogModule
|
||||
syslogmodule.Init("system", sysmodule.LEVER_INFO)
|
||||
syslogmodule.SetModuleType(sysmodule.SYS_LOG)
|
||||
syslogmodule.SetModuleId(sysmodule.SYS_LOG)
|
||||
AddModule(&syslogmodule)
|
||||
|
||||
err := cluster.InstanceClusterMgr().Init()
|
||||
@@ -107,7 +112,7 @@ func NewOrginNode() *COriginNode {
|
||||
return nil
|
||||
}
|
||||
|
||||
return new(COriginNode)
|
||||
return node
|
||||
}
|
||||
|
||||
func HasCmdParam(param string) bool {
|
||||
|
||||
Reference in New Issue
Block a user