diff options
Diffstat (limited to 'client/go/cmd/status.go')
-rw-r--r-- | client/go/cmd/status.go | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/client/go/cmd/status.go b/client/go/cmd/status.go new file mode 100644 index 00000000000..a011678be09 --- /dev/null +++ b/client/go/cmd/status.go @@ -0,0 +1,59 @@ +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// vespa status command +// author: bratseth + +package cmd + +import ( + "github.com/spf13/cobra" + "github.com/vespa-engine/vespa/util" +) + +func init() { + rootCmd.AddCommand(statusCmd) + statusCmd.AddCommand(statusContainerCmd) + statusCmd.AddCommand(statusConfigServerCmd) +} + +var statusCmd = &cobra.Command{ + Use: "status", + Short: "Verifies that a vespa target is ready to use (container by default)", + Long: `TODO`, + Run: func(cmd *cobra.Command, args []string) { + status(getTarget(queryContext).query, "Container") + }, +} + +var statusContainerCmd = &cobra.Command{ + Use: "container", + Short: "Verifies that your Vespa container endpoint is ready [Default]", + Long: `TODO`, + Run: func(cmd *cobra.Command, args []string) { + status(getTarget(queryContext).query, "Container") + }, +} + +var statusConfigServerCmd = &cobra.Command{ + Use: "config-server", + Short: "Verifies that your Vespa config server endpoint is ready", + Long: `TODO`, + Run: func(cmd *cobra.Command, args []string) { + status(getTarget(deployContext).deploy, "Config server") + }, +} + +func status(target string, description string) { + path := "/ApplicationStatus" + response := util.HttpGet(target, path, description) + if (response == nil) { + return + } + defer response.Body.Close() + + if response.StatusCode != 200 { + util.Error(description, "at", target, "is not ready") + util.Detail(response.Status) + } else { + util.Success(description, "at", target, "is ready") + } +} |