-
Notifications
You must be signed in to change notification settings - Fork 8
/
fix.go
56 lines (48 loc) · 1.2 KB
/
fix.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
46
47
48
49
50
51
52
53
54
55
56
package main
import (
"errors"
"fmt"
"github.com/Sirupsen/logrus"
"github.com/codegangsta/cli"
)
// fix host:port
// --timeout <arg>
var fixCommand = cli.Command{
Name: "fix",
Usage: "fix the redis cluster.",
ArgsUsage: `host:port`,
Description: `The fix command for fix the redis cluster.`,
Flags: []cli.Flag{
cli.IntFlag{
Name: "timeout, t",
Value: MigrateDefaultTimeout,
Usage: `timeout for fix the redis cluster.`,
},
},
Action: func(context *cli.Context) error {
if context.NArg() != 1 {
fmt.Printf("Incorrect Usage.\n\n")
cli.ShowCommandHelp(context, "fix")
logrus.Fatalf("Must provide at least \"host:port\" for fix command!")
}
rt := NewRedisTrib()
if err := rt.FixClusterCmd(context); err != nil {
return err
}
return nil
},
}
func (self *RedisTrib) FixClusterCmd(context *cli.Context) error {
var addr string
if addr = context.Args().Get(0); addr == "" {
return errors.New("please check host:port for fix command")
}
self.SetFix(true)
timeout := context.Int("timeout")
self.SetTimeout(timeout)
if err := self.LoadClusterInfoFromNode(addr); err != nil {
return err
}
self.CheckCluster(false)
return nil
}