Set notifications for SIGTERM and SIGINT when we start the cli
This commit is contained in:
parent
f3830b60ae
commit
88d59f6a5f
@ -4,6 +4,8 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
ufcli "github.com/urfave/cli/v2"
|
||||
"golang.org/x/xerrors"
|
||||
@ -36,6 +38,13 @@ func IncorrectNumArgs(cctx *ufcli.Context) error {
|
||||
}
|
||||
|
||||
func RunApp(app *ufcli.App) {
|
||||
c := make(chan os.Signal, 1)
|
||||
signal.Notify(c, syscall.SIGTERM, syscall.SIGINT)
|
||||
go func() {
|
||||
<-c
|
||||
os.Exit(1)
|
||||
}()
|
||||
|
||||
if err := app.Run(os.Args); err != nil {
|
||||
if os.Getenv("LOTUS_DEV") != "" {
|
||||
log.Warnf("%+v", err)
|
||||
|
@ -51,6 +51,7 @@ func MonitorShutdown(triggerCh <-chan struct{}, handlers ...ShutdownHandler) <-c
|
||||
close(out)
|
||||
}()
|
||||
|
||||
signal.Reset(syscall.SIGTERM, syscall.SIGINT)
|
||||
signal.Notify(sigCh, syscall.SIGTERM, syscall.SIGINT)
|
||||
return out
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user