From e097ba8640acd532e2cba41f77e4088d77317179 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 8 Jun 2021 14:22:16 -0700 Subject: [PATCH] feat(lotus-sim): wire up signal handler --- cmd/lotus-sim/main.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cmd/lotus-sim/main.go b/cmd/lotus-sim/main.go index 13b5d2282..bfcad728d 100644 --- a/cmd/lotus-sim/main.go +++ b/cmd/lotus-sim/main.go @@ -1,8 +1,11 @@ package main import ( + "context" "fmt" "os" + "os/signal" + "syscall" logging "github.com/ipfs/go-log/v2" "github.com/urfave/cli/v2" @@ -44,7 +47,11 @@ func main() { }, } - if err := app.Run(os.Args); err != nil { + ctx, cancel := signal.NotifyContext(context.Background(), + syscall.SIGTERM, syscall.SIGINT, syscall.SIGHUP) + defer cancel() + + if err := app.RunContext(ctx, os.Args); err != nil { fmt.Fprintf(os.Stderr, "Error: %s\n", err) os.Exit(1) return