diff --git a/cmd/soft/serve/serve.go b/cmd/soft/serve/serve.go index d23ce65d..8d846450 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)