Print a better error when the daemon isn't running (fix #39)

pull/92/head
Roey Darwish Dror 6 years ago
parent d10d7099de
commit 88f503f27f
  1. 5
      cmd/control/cmd/status.go

@ -24,7 +24,9 @@ var statusCmd = &cobra.Command{
fmt.Println(" * installed: " + version + " (" + commit + ")") fmt.Println(" * installed: " + version + " (" + commit + ")")
resp, err := getDaemonStatus(config.Port) resp, err := getDaemonStatus(config.Port)
if err != nil { if err != nil {
fmt.Println(" * daemon: NOT RUNNING!") fmt.Println(" * RESH-DAEMON IS NOT RUNNING")
exitCode = status.Fail
return
} else { } else {
fmt.Println(" * daemon: " + resp.Version + " (" + resp.Commit + ")") fmt.Println(" * daemon: " + resp.Version + " (" + resp.Commit + ")")
} }
@ -65,7 +67,6 @@ func getDaemonStatus(port int) (msg.StatusResponse, error) {
url := "http://localhost:" + strconv.Itoa(port) + "/status" url := "http://localhost:" + strconv.Itoa(port) + "/status"
resp, err := http.Get(url) resp, err := http.Get(url)
if err != nil { if err != nil {
log.Println("Daemon is not running!", err)
return mess, err return mess, err
} }
defer resp.Body.Close() defer resp.Body.Close()

Loading…
Cancel
Save