diff options
author | Valery Piashchynski <[email protected]> | 2020-02-21 18:02:33 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2020-02-21 18:02:33 +0300 |
commit | b2a19749a3e02f38c50e9023a22c60b679933c97 (patch) | |
tree | d192af0c58907ce110ab3bdcb1dd839196a02d8b /service/reload/service.go | |
parent | b44167f66258712df47c21896961756f8be672df (diff) |
Add tests
Add reload tests to Makefile
Remove old code
Diffstat (limited to 'service/reload/service.go')
-rw-r--r-- | service/reload/service.go | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/service/reload/service.go b/service/reload/service.go index bb85e15d..ab249c41 100644 --- a/service/reload/service.go +++ b/service/reload/service.go @@ -28,7 +28,7 @@ func (s *Service) Init(cfg *Config, c service.Container) (bool, error) { var configs []WatcherConfig // mount Services to designated services - for serviceName, _ := range cfg.Services { + for serviceName := range cfg.Services { svc, _ := c.Get(serviceName) if ctrl, ok := svc.(roadrunner.Controllable); ok { tmp := cfg.Services[serviceName] @@ -50,7 +50,6 @@ func (s *Service) Init(cfg *Config, c service.Container) (bool, error) { recursive: config.Recursive, directories: config.Dirs, filterHooks: func(filename string, patterns []string) error { - for i := 0; i < len(patterns); i++ { if strings.Contains(filename, patterns[i]) { return nil @@ -83,24 +82,21 @@ func (s *Service) Serve() error { } go func() { - for { - select { - case e := <-s.watcher.Event: - println(fmt.Sprintf("[UPDATE] Service: %s, path to file: %s, filename: %s", e.service, e.path, e.info.Name())) - - srv := s.reloadConfig.Services[e.service] - - if srv.service != nil { - s := *srv.service - err := s.Server().Reset() - if err != nil { - fmt.Println(err) - } - } else { - s.watcher.mu.Lock() - delete(s.watcher.watcherConfigs, e.service) - s.watcher.mu.Unlock() + for e := range s.watcher.Event { + println(fmt.Sprintf("[UPDATE] Service: %s, path to file: %s, filename: %s", e.service, e.path, e.info.Name())) + + srv := s.reloadConfig.Services[e.service] + + if srv.service != nil { + s := *srv.service + err := s.Server().Reset() + if err != nil { + fmt.Println(err) } + } else { + s.watcher.mu.Lock() + delete(s.watcher.watcherConfigs, e.service) + s.watcher.mu.Unlock() } } }() |