diff options
author | Wolfy-J <[email protected]> | 2018-06-12 21:13:54 +0300 |
---|---|---|
committer | Wolfy-J <[email protected]> | 2018-06-12 21:13:54 +0300 |
commit | 47aa87a1cd438c6c99a4640f6af60fd408b5c3bc (patch) | |
tree | b405ad7e1d3e6810c818be47a9cf67b7a534053c /service | |
parent | 99c1121d8fd31b7b61b6c22e181dc3c05a3f9f82 (diff) |
improved worker watching
Diffstat (limited to 'service')
-rw-r--r-- | service/container.go | 1 | ||||
-rw-r--r-- | service/http/rpc.go | 7 | ||||
-rw-r--r-- | service/http/service.go | 8 |
3 files changed, 6 insertions, 10 deletions
diff --git a/service/container.go b/service/container.go index 1233b30d..56350be7 100644 --- a/service/container.go +++ b/service/container.go @@ -140,6 +140,7 @@ func (c *container) Serve() error { defer e.setStatus(StatusStopped) if err := e.svc.Serve(); err != nil { + c.log.Errorf("[%s]: %s", e.name, err) done <- errors.Wrap(err, fmt.Sprintf("[%s]", e.name)) } }(e) diff --git a/service/http/rpc.go b/service/http/rpc.go index fc6aa65b..aebc5903 100644 --- a/service/http/rpc.go +++ b/service/http/rpc.go @@ -34,12 +34,7 @@ func (rpc *rpcServer) Reset(reset bool, r *string) error { } *r = "OK" - - for _, w := range rpc.svc.rr.Workers() { - w.Kill() - } - - return nil //rpc.svc.rr.Reset() + return rpc.svc.rr.Reset() } // Workers returns list of active workers and their stats. diff --git a/service/http/service.go b/service/http/service.go index a3773468..dc89c188 100644 --- a/service/http/service.go +++ b/service/http/service.go @@ -19,9 +19,9 @@ type middleware interface { // Service manages rr, http servers. type Service struct { cfg *Config - listeners []func(event int, ctx interface{}) - middleware []middleware + lsns []func(event int, ctx interface{}) rr *roadrunner.Server + middleware []middleware srv *Handler http *http.Server } @@ -32,7 +32,7 @@ func (s *Service) AddMiddleware(m middleware) { // AddListener attaches server event watcher. func (s *Service) AddListener(l func(event int, ctx interface{})) { - s.listeners = append(s.listeners, l) + s.lsns = append(s.lsns, l) } // Configure must return configure svc and return true if svc hasStatus enabled. Must return error in case of @@ -113,7 +113,7 @@ func (s *Service) ServeHTTP(w http.ResponseWriter, r *http.Request) { } func (s *Service) listener(event int, ctx interface{}) { - for _, l := range s.listeners { + for _, l := range s.lsns { l(event, ctx) } |