Skip to content

fix ugly error message when killing commands #1064

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 12, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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