@cryptotaxi247 / kubo / commits / f74e71f96

fix ugly error message when killing commands

Jeromy committed Apr 12, 2015 at 14:49 UTC f74e71f96545b14f5293c9851ce624aecddb68aa
1 file changed +15 -13
cmd/ipfs/main.go
+15 -13
@@ -496,22 +496,24 @@ func (i *cmdInvocation) setupInterruptHandler() {
496 case <-ctx.InitDone:
497 }
498
499 - // TODO cancel the command context instead
500 -
501 - n, err := ctx.GetNode()
502 - if err != nil {
503 - log.Error(err)
504 - fmt.Println(shutdownMessage)
505 - os.Exit(-1)
506 - }
507 -
499 switch count {
500 case 0:
501 fmt.Println(shutdownMessage)
511 - go func() {
512 - n.Close()
513 - log.Info("Gracefully shut down.")
514 - }()
502 + if ctx.Online {
503 + go func() {
504 + // TODO cancel the command context instead
505 + n, err := ctx.GetNode()
506 + if err != nil {
507 + log.Error(err)
508 + fmt.Println(shutdownMessage)
509 + os.Exit(-1)
510 + }
511 + n.Close()
512 + log.Info("Gracefully shut down.")
513 + }()
514 + } else {
515 + os.Exit(0)
516 + }
517
518 default:
519 fmt.Println("Received another interrupt before graceful shutdown, terminating...")