From f74e71f96545b14f5293c9851ce624aecddb68aa Mon Sep 17 00:00:00 2001
From: Jeromy <jeromyj@gmail.com>
Date: Sun, 12 Apr 2015 14:49:45 -0700
Subject: [PATCH] fix ugly error message when killing commands

---
 cmd/ipfs/main.go | 28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/cmd/ipfs/main.go b/cmd/ipfs/main.go
index b5c38911..76d71a63 100644
--- a/cmd/ipfs/main.go
+++ b/cmd/ipfs/main.go
@@ -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...")
-- 
GitLab