Maint: better log when cathing an OS signal

This commit is contained in:
Quentin McGaw (desktop)
2021-08-18 21:22:27 +00:00
parent 0027a76c49
commit 538bc72c3c

View File

@@ -59,9 +59,9 @@ func main() {
Created: created,
}
ctx := context.Background()
ctx, stop := signal.NotifyContext(ctx, syscall.SIGINT, syscall.SIGTERM, os.Interrupt)
ctx, cancel := context.WithCancel(ctx)
background := context.Background()
signalCtx, stop := signal.NotifyContext(background, syscall.SIGINT, syscall.SIGTERM, os.Interrupt)
ctx, cancel := context.WithCancel(background)
logger := logging.NewParent(logging.Settings{
Level: logging.LevelInfo,
@@ -79,9 +79,11 @@ func main() {
}()
select {
case <-ctx.Done():
case <-signalCtx.Done():
stop()
fmt.Println("")
logger.Warn("Caught OS signal, shutting down")
cancel()
case err := <-errorCh:
stop()
close(errorCh)