-
Notifications
You must be signed in to change notification settings - Fork 18
/
main.go
42 lines (35 loc) · 988 Bytes
/
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
package main
import (
"fmt"
"os"
"github.com/Cepave/open-falcon-backend/cmd"
"github.com/spf13/cobra"
)
var versionFlag bool
var RootCmd = &cobra.Command{
Use: "open-falcon",
RunE: func(c *cobra.Command, args []string) error {
if versionFlag {
fmt.Printf("Open-Falcon version %s, build %s\n", Version, GitCommit)
return nil
}
return c.Usage()
},
}
func init() {
RootCmd.AddCommand(cmd.Start)
RootCmd.AddCommand(cmd.Stop)
RootCmd.AddCommand(cmd.Restart)
RootCmd.AddCommand(cmd.Check)
RootCmd.AddCommand(cmd.Monitor)
RootCmd.AddCommand(cmd.Reload)
RootCmd.Flags().BoolVarP(&versionFlag, "version", "v", false, "show version")
cmd.Start.Flags().BoolVar(&cmd.PreqOrderFlag, "preq-order", false, "start modules in the order of prerequisites")
cmd.Start.Flags().BoolVar(&cmd.ConsoleOutputFlag, "console-output", false, "print the module's output to the console")
}
func main() {
if err := RootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}