mirror of
https://github.com/ipfs/kubo.git
synced 2025-07-03 13:00:37 +08:00
fix ugly error message when killing commands
This commit is contained in:
@ -496,22 +496,24 @@ func (i *cmdInvocation) setupInterruptHandler() {
|
|||||||
case <-ctx.InitDone:
|
case <-ctx.InitDone:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch count {
|
||||||
|
case 0:
|
||||||
|
fmt.Println(shutdownMessage)
|
||||||
|
if ctx.Online {
|
||||||
|
go func() {
|
||||||
// TODO cancel the command context instead
|
// TODO cancel the command context instead
|
||||||
|
|
||||||
n, err := ctx.GetNode()
|
n, err := ctx.GetNode()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
fmt.Println(shutdownMessage)
|
fmt.Println(shutdownMessage)
|
||||||
os.Exit(-1)
|
os.Exit(-1)
|
||||||
}
|
}
|
||||||
|
|
||||||
switch count {
|
|
||||||
case 0:
|
|
||||||
fmt.Println(shutdownMessage)
|
|
||||||
go func() {
|
|
||||||
n.Close()
|
n.Close()
|
||||||
log.Info("Gracefully shut down.")
|
log.Info("Gracefully shut down.")
|
||||||
}()
|
}()
|
||||||
|
} else {
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fmt.Println("Received another interrupt before graceful shutdown, terminating...")
|
fmt.Println("Received another interrupt before graceful shutdown, terminating...")
|
||||||
|
Reference in New Issue
Block a user