From 972f9ca4fb972b911763f186454635c96db51964 Mon Sep 17 00:00:00 2001 From: insanity Date: Wed, 4 Jul 2018 19:46:56 +0900 Subject: [PATCH] test --- Gopkg.lock | 13 +---- main.go | 2 +- service/CollectorService.go | 95 ------------------------------------- service/CrawlerService.go | 5 -- service/service.go | 1 - 5 files changed, 3 insertions(+), 113 deletions(-) delete mode 100644 service/CollectorService.go diff --git a/Gopkg.lock b/Gopkg.lock index c7f58cd..8adc232 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -63,7 +63,7 @@ "time/scheduler/storage", "time/scheduler/task" ] - revision = "4d4017d214d2a8fdde59d774254f421991fabe7e" + revision = "dd4f956c587b1947f84ad5eebd64722b3d6c5224" [[projects]] branch = "master" @@ -87,7 +87,7 @@ "model/sensorconfig", "service/probe" ] - revision = "904de1632643ddb9c8862cd5bf147570c1a59878" + revision = "e2c0324eb632822050f3d0379ddd1a13c2aac2b1" [[projects]] name = "github.com/BurntSushi/toml" @@ -136,21 +136,12 @@ branch = "master" name = "github.com/shirou/gopsutil" packages = [ - "cpu", "host", "internal/common", - "mem", - "net", "process" ] revision = "1c49dd8c6f1ec1a36ff6e98cc6ddda727a800219" -[[projects]] - branch = "master" - name = "github.com/shirou/w32" - packages = ["."] - revision = "bb4de0191aa41b5507caa14b0650cdbddcd9280b" - [[projects]] name = "github.com/valyala/fasthttp" packages = [ diff --git a/main.go b/main.go index aaac53d..af23c66 100644 --- a/main.go +++ b/main.go @@ -71,7 +71,7 @@ func main() { interrupt := make(chan os.Signal, 1) signal.Notify(interrupt, syscall.SIGKILL, - syscall.SIGSTOP, + // syscall.SIGSTOP, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, diff --git a/service/CollectorService.go b/service/CollectorService.go deleted file mode 100644 index 4ed3bd6..0000000 --- a/service/CollectorService.go +++ /dev/null @@ -1,95 +0,0 @@ -package service - -import ( - "fmt" - "reflect" - "time" - - cda "git.loafle.net/commons/di-go/annotation" - cdr "git.loafle.net/commons/di-go/registry" - cuts "git.loafle.net/commons/util-go/time/scheduler" - cutss "git.loafle.net/commons/util-go/time/scheduler/storage" - ocmsc "git.loafle.net/overflow/commons-go/model/sensorconfig" - ocsp "git.loafle.net/overflow/commons-go/service/probe" - - // For annotation - _ "git.loafle.net/overflow/commons-go/core/annotation" -) - -var CollectorServiceType = reflect.TypeOf((*CollectorService)(nil)) - -func init() { - cdr.RegisterType(CollectorServiceType) -} - -type CollectorService struct { - ocsp.CollectorService - cda.TypeAnnotation `annotation:"@overflow:RPCService()"` - - ContainerService *ContainerService `annotation:"@Inject()"` - SensorConfigService *SensorConfigService `annotation:"@Inject()"` - - scheduler *cuts.Scheduler -} - -func (s *CollectorService) InitService() error { - _storage := cutss.NewMemoryStorage() - s.scheduler = cuts.New(_storage) - - return nil -} - -func (s *CollectorService) StartService() error { - if err := s.scheduler.Start(); nil != err { - return fmt.Errorf("CollectorService: StartService failed %v", err) - } - - if err := s.addScheduleAll(); nil != err { - return err - } - return nil -} - -func (s *CollectorService) StopService() { - s.scheduler.Stop() -} - -func (s *CollectorService) DestroyService() { - -} - -func (s *CollectorService) addScheduleAll() error { - sensorConfigs := s.SensorConfigService.sensorConfigs - if nil == sensorConfigs || 0 == len(sensorConfigs) { - return nil - } - - //for _, sensorConfig := range sensorConfigs { - // interval, err := strconv.ParseInt(sensorConfig.Schedule.Interval, 10, 64) - // if nil != err { - // return fmt.Errorf("Cannot convert interval[%s] %v", sensorConfig.Schedule.Interval, err) - // } - // s.addSchedule(interval, sensorConfig) - //} - - return nil -} - -func (s *CollectorService) addSchedule(interval int64, sensorConfig *ocmsc.SensorConfig) { - s.scheduler.RunEvery(time.Duration(interval)*time.Second, s.collectTask, sensorConfig) -} - -func (s *CollectorService) collectTask(sensorConfig *ocmsc.SensorConfig) { - // go func(_sensorConfig *ocmsc.SensorConfig) { - // logging.Logger().Debugf("CollectorService.collectTask for sensor config id[%s] container[%s] crawler[%s]", _sensorConfig.ConfigID, _sensorConfig.Crawler.Container, _sensorConfig.Crawler.Name) - // var result map[string]string - // err := s.ContainerService.Call(occp.ToContainerType(_sensorConfig.Crawler.Container), &result, "CrawlerService.Get", _sensorConfig.ConfigID) - // if nil != err { - // logging.Logger().Errorf("Cannot get data from crawler[%s] of container[%s] %v", _sensorConfig.Crawler.Name, _sensorConfig.Crawler.Container, err) - // return - // } - // logging.Logger().Debugf("Data[%v] received from crawler[%s] of container[%s]", result, _sensorConfig.Crawler.Name, _sensorConfig.Crawler.Container) - - // //cs.CentralService.Send(oocmp.HTTPEntry_Data, "CrawlerService.Data", result) - // }(sensorConfig) -} diff --git a/service/CrawlerService.go b/service/CrawlerService.go index 172cbb8..f7fc3d6 100644 --- a/service/CrawlerService.go +++ b/service/CrawlerService.go @@ -41,8 +41,3 @@ func (s *CrawlerService) StopService() { func (s *CrawlerService) DestroyService() { } - -func (s *CrawlerService) Accept() error { - - return nil -} diff --git a/service/service.go b/service/service.go index 74cd586..40b4716 100644 --- a/service/service.go +++ b/service/service.go @@ -9,7 +9,6 @@ var ( ContainerServiceType, SensorConfigServiceType, CrawlerServiceType, - CollectorServiceType, DiscoveryServiceType, SensorServiceType, }