mirror of
https://github.com/duanhf2012/origin.git
synced 2026-02-03 22:45:13 +08:00
51 lines
674 B
Go
51 lines
674 B
Go
package service
|
|
|
|
//本地所有的service
|
|
var mapServiceName map[string]IService
|
|
|
|
func init(){
|
|
mapServiceName = map[string]IService{}
|
|
}
|
|
|
|
func Init(chanCloseSig chan bool) {
|
|
closeSig=chanCloseSig
|
|
|
|
for _,s := range mapServiceName {
|
|
s.OnInit()
|
|
}
|
|
}
|
|
|
|
|
|
func Setup(s IService) bool {
|
|
_,ok := mapServiceName[s.GetName()]
|
|
if ok == true {
|
|
return false
|
|
}
|
|
|
|
mapServiceName[s.GetName()] = s
|
|
return true
|
|
}
|
|
|
|
func GetService(servicename string) IService {
|
|
s,ok := mapServiceName[servicename]
|
|
if ok == false {
|
|
return nil
|
|
}
|
|
|
|
return s
|
|
}
|
|
|
|
|
|
func Start(){
|
|
for _,s := range mapServiceName {
|
|
s.Start()
|
|
}
|
|
}
|
|
|
|
func WaitStop(){
|
|
for _,s := range mapServiceName {
|
|
s.Wait()
|
|
}
|
|
}
|
|
|