feat(lotus-sim): wire up signal handler
This commit is contained in:
parent
4578e0dd8d
commit
e097ba8640
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user