summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2021-07-02 16:11:26 +0200
committerJon Bratseth <bratseth@gmail.com>2021-07-02 16:11:26 +0200
commit8c6dae13c3f48ef125323bc735be4fd2c80b82de (patch)
treee3212cde55fd96a7128d7ad8ee59018dd4b9cc2f /client
parentc756800d71c31d0f263fe9d51551ede96e596eb2 (diff)
Print status nicely
Diffstat (limited to 'client')
-rw-r--r--client/src/main/go/vespa.go27
1 files changed, 14 insertions, 13 deletions
diff --git a/client/src/main/go/vespa.go b/client/src/main/go/vespa.go
index e0bf5bef199..ea1cf7f1bab 100644
--- a/client/src/main/go/vespa.go
+++ b/client/src/main/go/vespa.go
@@ -4,6 +4,7 @@ import (
"bufio"
"fmt"
"net/http"
+ "strings"
)
func main() {
@@ -11,32 +12,32 @@ func main() {
}
func status() {
+ // See https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit
// colorReset := "\033[0m"
- // colorRed := "\033[31m"
- // colorGreen := "\033[32m"
- colorYellow := "\033[33m"
+ colorRed := "\033[31m"
+ colorGreen := "\033[32m"
// colorBlue := "\033[34m"
- // colorPurple := "\033[35m"
- // colorCyan := "\033[36m"
- // colorWhite := "\033[37m"
+ colorYellow := "\033[33m"
- target := "http://127.0.0.1:19072"
+ target := "http://127.0.0.1:19071"
+ targetName := "Config server"
resp, err := http.Get(target + "/ApplicationStatus")
if err != nil {
- fmt.Println("Could not connect to config server at", target)
+ fmt.Println(colorRed + "Could not connect to", strings.ToLower(targetName), "at", target)
fmt.Println(colorYellow + err.Error())
return
}
defer resp.Body.Close()
- fmt.Println("Response status: ", resp.Status)
scanner := bufio.NewScanner(resp.Body)
if err := scanner.Err(); err != nil {
- fmt.Println(err)
+ fmt.Println(colorRed + "Error reading data from", strings.ToLower(targetName), "at", target)
+ fmt.Println(colorYellow + err.Error())
+ } else if resp.StatusCode != 200 {
+ fmt.Println(colorRed + targetName, "at", target, " is not handling requests")
+ fmt.Println(colorYellow + "Response status", resp.StatusCode)
} else {
- for i := 0; scanner.Scan() && i < 5; i++ {
- fmt.Println(scanner.Text())
- }
+ fmt.Println(colorGreen + targetName, "at", target, "is UP")
}
}