-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
42 lines (36 loc) · 856 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/domdom82/go-backpressure/client"
"github.com/domdom82/go-backpressure/server"
)
func main() {
usage := func() {
fmt.Printf("Usage: %s <-client|-server> <configfile>\n", os.Args[0])
os.Exit(1)
}
if len(os.Args) > 2 {
if os.Args[1] == "-server" {
fmt.Printf("Loading server config from %q\n", os.Args[2])
s, err := server.NewServerConfigFromFile(os.Args[2])
if err != nil {
fmt.Println(err)
os.Exit(1)
}
fmt.Printf("Starting the server.\n")
s.NewServer().Run()
} else if os.Args[1] == "-client" {
fmt.Printf("Loading client config from %q\n", os.Args[2])
c, err := client.NewClientConfigFromFile(os.Args[2])
if err != nil {
fmt.Println(err)
os.Exit(1)
}
fmt.Printf("Starting the client.\n")
c.NewClient().Run()
}
} else {
usage()
}
}