From aa15af54fbf27042f16ab072d2242965bad5690a Mon Sep 17 00:00:00 2001 From: Ayman Bagabas Date: Tue, 30 Jul 2024 17:50:40 -0400 Subject: [PATCH] fix: tidy notify os interrupt signals --- cmd/soft/serve/serve.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/soft/serve/serve.go b/cmd/soft/serve/serve.go index d23ce65de..8d8464504 100644 --- a/cmd/soft/serve/serve.go +++ b/cmd/soft/serve/serve.go @@ -82,10 +82,11 @@ var ( } } + lch := make(chan error, 1) done := make(chan os.Signal, 1) doneOnce := sync.OnceFunc(func() { close(done) }) - lch := make(chan error, 1) + signal.Notify(done, os.Interrupt, syscall.SIGINT, syscall.SIGTERM) // This endpoint is added for testing purposes // It allows us to stop the server from the test suite. @@ -102,11 +103,10 @@ var ( } go func() { - defer doneOnce() lch <- s.Start() + doneOnce() }() - signal.Notify(done, os.Interrupt, syscall.SIGINT, syscall.SIGTERM) <-done ctx, cancel := context.WithTimeout(ctx, 30*time.Second)