diff options
author | Wolfy-J <[email protected]> | 2018-06-23 20:27:37 +0300 |
---|---|---|
committer | Wolfy-J <[email protected]> | 2018-06-23 20:27:37 +0300 |
commit | 69e6ffecc4ac76e97e463ef2442ba86eebf35d27 (patch) | |
tree | 05b86490a9d0e7a4a1edec835463821aa889fb80 | |
parent | 4d3042eb47f6f4d49f044d0b0ef6e26570642452 (diff) |
no need for stopping flag
-rw-r--r-- | service/http/service.go | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/service/http/service.go b/service/http/service.go index b89bfe99..f171e48e 100644 --- a/service/http/service.go +++ b/service/http/service.go @@ -7,6 +7,7 @@ import ( "github.com/spiral/roadrunner/service/rpc" "net/http" "sync" + "sync/atomic" ) // ID contains default svc name. @@ -20,10 +21,12 @@ type Service struct { cfg *Config lsns []func(event int, ctx interface{}) mdws []middleware - mu sync.Mutex - rr *roadrunner.Server - srv *Handler - http *http.Server + + mu sync.Mutex + rr *roadrunner.Server + stopping int32 + srv *Handler + http *http.Server } // AddMiddleware adds new net/http middleware. @@ -120,9 +123,11 @@ func (s *Service) listener(event int, ctx interface{}) { } if event == roadrunner.EventServerFailure { - // attempting rr server restart - if err := s.rr.Start(); err != nil { - s.Stop() + if atomic.LoadInt32(&s.stopping) != 0 { + // attempting rr server restart + if err := s.rr.Start(); err != nil { + s.Stop() + } } } } |