-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
46 lines (38 loc) · 1.07 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
package main
import (
"flag"
"fmt"
"os"
"strings"
"github.com/artyomtkachenko/bmanager/apache"
)
var version string
func main() {
hostnameFlag := flag.String("hostname", "http://localhost", "A hostname searving the /balancer-manager URI")
actionFlag := flag.String("action", "status", "Action disable|enable|status")
hostsFlag := flag.String("hosts", "", "Comma-separated list of workers")
portFlag := flag.String("port", "80", "Workers port")
uriFlag := flag.String("uri", "", "Application uri")
debugFlag := flag.Bool("debug", false, "Enables debugging")
args := os.Args[1:]
for _, arg := range args {
if arg == "-v" || arg == "-version" || arg == "--version" {
fmt.Println(version)
os.Exit(0)
}
}
flag.Parse()
hosts := strings.Split(*hostsFlag, ",")
instance := apache.Apache{
Url: *hostnameFlag + "/balancer-manager",
Debug: *debugFlag,
}
switch *actionFlag {
case "enable":
instance.Enable(hosts, *portFlag, *uriFlag)
case "disable":
instance.Disable(hosts, *portFlag, *uriFlag)
case "status":
instance.Status(hosts, *portFlag, *uriFlag)
}
}