From d75eb8bb4e35c37c96fbb9cf9015ea3f9ba542ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philip=20Dub=C3=A9?= Date: Tue, 20 Feb 2024 15:04:52 +0000 Subject: [PATCH] cmd/main: use signal.NotifyContext (#1332) --- flow/cmd/main.go | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/flow/cmd/main.go b/flow/cmd/main.go index d6d23ff1ab..f7fa4734fb 100644 --- a/flow/cmd/main.go +++ b/flow/cmd/main.go @@ -15,17 +15,10 @@ import ( ) func main() { - appCtx, appCancel := context.WithCancel(context.Background()) - slog.SetDefault(slog.New(logger.NewHandler(slog.NewJSONHandler(os.Stdout, nil)))) - // setup shutdown handling - quit := make(chan os.Signal, 1) - signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM) + appCtx, appClose := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + defer appClose() - // cancel the context when we receive a shutdown signal - go func() { - <-quit - appCancel() - }() + slog.SetDefault(slog.New(logger.NewHandler(slog.NewJSONHandler(os.Stdout, nil)))) temporalHostPortFlag := &cli.StringFlag{ Name: "temporal-host-port", @@ -144,6 +137,6 @@ func main() { } if err := app.Run(appCtx, os.Args); err != nil { - log.Fatalf("error running app: %v", err) + log.Printf("error running app: %+v", err) } }