aa15af54fbf27042f16ab072d2242965bad5690a

Author
Ayman Bagabas <ayman.bagabas@gmail.com>
Committer
Ayman Bagabas <ayman.bagabas@gmail.com>
Date

Message

fix: tidy notify os interrupt signals

Diff

 1diff --git a/cmd/soft/serve/serve.go b/cmd/soft/serve/serve.go
 2index d23ce65de3b5c4c7f1883b6f384edbf646b30824..8d8464504423032c08159df1953cb99588c893a9 100644
 3--- a/cmd/soft/serve/serve.go
 4+++ b/cmd/soft/serve/serve.go
 5@@ -82,10 +82,11 @@ var (
 6 				}
 7 			}
 8 
 9+			lch := make(chan error, 1)
10 			done := make(chan os.Signal, 1)
11 			doneOnce := sync.OnceFunc(func() { close(done) })
12 
13-			lch := make(chan error, 1)
14+			signal.Notify(done, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
15 
16 			// This endpoint is added for testing purposes
17 			// It allows us to stop the server from the test suite.
18@@ -102,11 +103,10 @@ var (
19 			}
20 
21 			go func() {
22-				defer doneOnce()
23 				lch <- s.Start()
24+				doneOnce()
25 			}()
26 
27-			signal.Notify(done, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
28 			<-done
29 
30 			ctx, cancel := context.WithTimeout(ctx, 30*time.Second)