package server import ( "reflect" cdr "git.loafle.net/commons_go/di/registry" "git.loafle.net/commons_go/logging" crr "git.loafle.net/commons_go/rpc/registry" "git.loafle.net/commons_go/server" ooca "git.loafle.net/overflow/overflow_commons_go/annotation" oopc "git.loafle.net/overflow/overflow_probe_container" oopcs "git.loafle.net/overflow/overflow_probe_container/server" oopcService "git.loafle.net/overflow/overflow_probe_container/service" "git.loafle.net/overflow/overflow_probe_container_network/crawler" oopcns "git.loafle.net/overflow/overflow_probe_container_network/service" ) func New(pidPath string) server.Server { var ( services []interface{} probeService *oopcService.ProbeService err error ) oopcns.InitService() cdr.RegisterResource(oopc.PROBE_CONTAINER_CRAWLERS, crawler.GetCrawlers()) rpcRegistry := crr.NewRPCRegistry() if services, err = cdr.GetInstancesByAnnotationName(ooca.ServiceTag); nil != err { logging.Logger().Panic(err) } for _, s := range services { rpcRegistry.RegisterService(s, "") } if _probeService, err := cdr.GetInstance(reflect.TypeOf((*oopcService.ProbeService)(nil))); nil != err { logging.Logger().Panic(err) } else { probeService = _probeService.(*oopcService.ProbeService) } rpcSH := oopcs.NewRPCServletHandler(rpcRegistry) socketHandler := newSocketHandler(rpcSH, probeService) sh := newServerHandler(pidPath, socketHandler, services, oopcns.ServicesToStartAndStop) s := oopcs.New(sh) return s }