diff options
author | Wolfy-J <[email protected]> | 2018-06-23 20:21:12 +0300 |
---|---|---|
committer | Wolfy-J <[email protected]> | 2018-06-23 20:21:12 +0300 |
commit | 88b3416e0cb795873787014906b48d184f8fe78a (patch) | |
tree | 3fdebb92ef36277a43b9303703d8f22aa8edf9dd | |
parent | 008a42fc6138e74766cdf9011a8dfc60df71b4a0 (diff) |
better shutdown
-rw-r--r-- | cmd/rr/cmd/serve.go | 5 | ||||
-rw-r--r-- | server.go | 1 | ||||
-rw-r--r-- | service/http/service.go | 1 | ||||
-rw-r--r-- | service/rpc/service.go | 3 |
4 files changed, 7 insertions, 3 deletions
diff --git a/cmd/rr/cmd/serve.go b/cmd/rr/cmd/serve.go index 4ae2a9d9..dc751611 100644 --- a/cmd/rr/cmd/serve.go +++ b/cmd/rr/cmd/serve.go @@ -40,7 +40,10 @@ func init() { } func serveHandler(cmd *cobra.Command, args []string) error { - go Container.Serve() + go func() { + Container.Serve() + stopSignal <- nil + }() <-stopSignal Container.Stop() @@ -64,6 +64,7 @@ func (s *Server) Start() (err error) { defer s.mu.Unlock() if s.factory, err = s.cfg.makeFactory(); err != nil { + return err } diff --git a/service/http/service.go b/service/http/service.go index 2df8656c..7fad3c49 100644 --- a/service/http/service.go +++ b/service/http/service.go @@ -105,7 +105,6 @@ func (s *Service) Stop() { atomic.AddInt32(&s.inStopping, 1) defer atomic.AddInt32(&s.inStopping, -1) - s.http.Shutdown(context.Background()) } diff --git a/service/rpc/service.go b/service/rpc/service.go index e1147754..c301e6bb 100644 --- a/service/rpc/service.go +++ b/service/rpc/service.go @@ -60,10 +60,11 @@ func (s *Service) Serve() error { for { select { case <-s.stop: - break + return default: conn, err := ln.Accept() if err != nil { + continue } |