1
0
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:
Jeromy
2015-04-12 14:49:45 -07:00
parent 6036b043b1
commit f74e71f965

View File

@ -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...")