-
Notifications
You must be signed in to change notification settings - Fork 8
/
check.go
45 lines (37 loc) · 969 Bytes
/
check.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package main
import (
"errors"
"fmt"
"github.com/Sirupsen/logrus"
"github.com/codegangsta/cli"
)
// check host:port
var checkCommand = cli.Command{
Name: "check",
Usage: "check the redis cluster.",
ArgsUsage: `host:port`,
Description: `The check command check for redis cluster.`,
Action: func(context *cli.Context) error {
if context.NArg() != 1 {
fmt.Printf("Incorrect Usage.\n\n")
cli.ShowCommandHelp(context, "check")
logrus.Fatalf("Must provide host:port for check command!")
}
rt := NewRedisTrib()
if err := rt.CheckClusterCmd(context); err != nil {
return err
}
return nil
},
}
func (self *RedisTrib) CheckClusterCmd(context *cli.Context) error {
var addr string
if addr = context.Args().Get(0); addr == "" {
return errors.New("please check host:port for check command")
}
if err := self.LoadClusterInfoFromNode(addr); err != nil {
return err
}
self.CheckCluster(false)
return nil
}