Skip to content

Commit

Permalink
pdctl support health check (#792)
Browse files Browse the repository at this point in the history
  • Loading branch information
Connor1996 authored and disksing committed Oct 12, 2017
1 parent ba9ff17 commit f5bf59e
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
44 changes: 44 additions & 0 deletions pdctl/command/health_command.go
@@ -0,0 +1,44 @@
// Copyright 2017 PingCAP, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// See the License for the specific language governing permissions and
// limitations under the License.

package command

import (
"fmt"
"net/http"

"github.com/spf13/cobra"
)

var (
healthPrefix = "health"
)

// NewHealthCommand return a health subcommand of rootCmd
func NewHealthCommand() *cobra.Command {
m := &cobra.Command{
Use: "health",
Short: "show the health information",
Run: showHealthCommandFunc,
}
return m
}

func showHealthCommandFunc(cmd *cobra.Command, args []string) {
r, err := doRequest(cmd, healthPrefix, http.MethodGet)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(r)
}
1 change: 1 addition & 0 deletions pdctl/ctl.go
Expand Up @@ -51,6 +51,7 @@ func init() {
command.NewHotSpotCommand(),
command.NewClusterCommand(),
command.NewNamespaceCommand(),
command.NewHealthCommand(),
)
cobra.EnablePrefixMatching = true
}
Expand Down

0 comments on commit f5bf59e

Please sign in to comment.