Skip to content

Commit

Permalink
fix ugly error message when killing commands
Browse files Browse the repository at this point in the history
  • Loading branch information
whyrusleeping committed Apr 12, 2015
1 parent 6036b04 commit f74e71f
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions cmd/ipfs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...")
Expand Down

0 comments on commit f74e71f

Please sign in to comment.