1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-07-02 03:28:25 +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:
}
// TODO cancel the command context instead
n, err := ctx.GetNode()
if err != nil {
log.Error(err)
fmt.Println(shutdownMessage)
os.Exit(-1)
}
switch count {
case 0:
fmt.Println(shutdownMessage)
go func() {
n.Close()
log.Info("Gracefully shut down.")
}()
if ctx.Online {
go func() {
// TODO cancel the command context instead
n, err := ctx.GetNode()
if err != nil {
log.Error(err)
fmt.Println(shutdownMessage)
os.Exit(-1)
}
n.Close()
log.Info("Gracefully shut down.")
}()
} else {
os.Exit(0)
}
default:
fmt.Println("Received another interrupt before graceful shutdown, terminating...")