feat(lotus-sim): wire up signal handler

This commit is contained in:
Steven Allen 2021-06-08 14:22:16 -07:00
parent 4578e0dd8d
commit e097ba8640

View File

@ -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