Skip to content

Commit f74e71f

Browse files
committed
fix ugly error message when killing commands
1 parent 6036b04 commit f74e71f

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

cmd/ipfs/main.go

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -496,22 +496,24 @@ func (i *cmdInvocation) setupInterruptHandler() {
496496
case <-ctx.InitDone:
497497
}
498498

499-
// TODO cancel the command context instead
500-
501-
n, err := ctx.GetNode()
502-
if err != nil {
503-
log.Error(err)
504-
fmt.Println(shutdownMessage)
505-
os.Exit(-1)
506-
}
507-
508499
switch count {
509500
case 0:
510501
fmt.Println(shutdownMessage)
511-
go func() {
512-
n.Close()
513-
log.Info("Gracefully shut down.")
514-
}()
502+
if ctx.Online {
503+
go func() {
504+
// TODO cancel the command context instead
505+
n, err := ctx.GetNode()
506+
if err != nil {
507+
log.Error(err)
508+
fmt.Println(shutdownMessage)
509+
os.Exit(-1)
510+
}
511+
n.Close()
512+
log.Info("Gracefully shut down.")
513+
}()
514+
} else {
515+
os.Exit(0)
516+
}
515517

516518
default:
517519
fmt.Println("Received another interrupt before graceful shutdown, terminating...")

0 commit comments

Comments
 (0)