forked from signal18/replication-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
53 lines (47 loc) · 1.8 KB
/
main.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
package main
import (
"fmt"
"os"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
func init() {
viper.SetConfigType("toml")
viper.SetConfigName("config")
viper.AddConfigPath("/etc/replication-manager/")
viper.AddConfigPath(".")
viper.ReadInConfig()
rootCmd.AddCommand(versionCmd)
rootCmd.PersistentFlags().StringVar(&user, "user", "", "User for MariaDB login, specified in the [user]:[password] format")
rootCmd.PersistentFlags().StringVar(&hosts, "hosts", "", "List of MariaDB hosts IP and port (optional), specified in the host:[port] format and separated by commas")
rootCmd.PersistentFlags().StringVar(&rpluser, "rpluser", "", "Replication user in the [user]:[password] format")
rootCmd.PersistentFlags().BoolVar(&interactive, "interactive", true, "Ask for user interaction when failures are detected")
rootCmd.PersistentFlags().BoolVar(&verbose, "verbose", false, "Print detailed execution info")
viper.BindPFlags(rootCmd.PersistentFlags())
user = viper.GetString("user")
hosts = viper.GetString("hosts")
rpluser = viper.GetString("rpluser")
}
func main() {
if err := rootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(-1)
}
}
var rootCmd = &cobra.Command{
Use: "replication-manager",
Short: "MariaDB Replication Manager Utility",
Long: `replication-manager allows users to monitor interactively MariaDB 10.x GTID replication health
and trigger slave to master promotion (aka switchover), or elect a new master in case of failure (aka failover).`,
Run: func(cmd *cobra.Command, args []string) {
cmd.Usage()
},
}
var versionCmd = &cobra.Command{
Use: "version",
Short: "Print the replication manager version number",
Long: `All software has versions. This is ours`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("MariaDB Replication Manager version", repmgrVersion)
},
}