diff options
author | Valery Piashchynski <[email protected]> | 2020-02-19 17:30:05 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2020-02-19 17:30:05 +0300 |
commit | 9cff24e4d515d684cefdf46624da90d22224aeaa (patch) | |
tree | b49142bcb1fd207065259f7693e36ab67f8eed58 /service/reload/service.go | |
parent | 24ec01aa7f0225098e4c750a8c51843cc41bbf8b (diff) |
First concept of reload
Diffstat (limited to 'service/reload/service.go')
-rw-r--r-- | service/reload/service.go | 58 |
1 files changed, 47 insertions, 11 deletions
diff --git a/service/reload/service.go b/service/reload/service.go index ee2aed99..78f147b7 100644 --- a/service/reload/service.go +++ b/service/reload/service.go @@ -3,6 +3,7 @@ package reload import ( "github.com/spiral/roadrunner/service" "os" + "time" ) // ID contains default service name. @@ -10,18 +11,12 @@ const ID = "reload" type Service struct { reloadConfig *Config + container service.Container } // Init controller service func (s *Service) Init(cfg *Config, c service.Container) (bool, error) { - // mount Services to designated services - //for id, watcher := range cfg.Controllers(s.throw) { - // svc, _ := c.Get(id) - // if ctrl, ok := svc.(controllable); ok { - // ctrl.Attach(watcher) - // } - //} - + s.container = c s.reloadConfig = cfg return true, nil @@ -33,11 +28,52 @@ func (s *Service) Serve() error { return err } - name , _ := os.Getwd() + name , err := os.Getwd() + if err != nil { + return err + } + + err = w.AddSingle(name) + if err != nil { + return err + } - w.AddSingle(name) + go func() { + err = w.StartPolling(time.Second) + if err != nil { + + } + }() + + + + // read events and restart corresponding services + + + for { + select { + case e := <- w.Event: + println(e.Name()) + } + } + //for e = range w.Event { + // + // println("event") + // // todo use status + // //svc, _ := s.container.Get("http") + // //if svc != nil { + // // if srv, ok := svc.(service.Service); ok { + // // srv.Stop() + // // err = srv.Serve() + // // if err != nil { + // // return err + // // } + // // } + // //} + // + // //println("event skipped due to service is nil") + //} - println("test") return nil } |