Skip to content

Commit

Permalink
cmd/main: use signal.NotifyContext (#1332)
Browse files Browse the repository at this point in the history
  • Loading branch information
serprex authored Feb 20, 2024
1 parent 3012a90 commit d75eb8b
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions flow/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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)
}
}

0 comments on commit d75eb8b

Please sign in to comment.