-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
74 lines (59 loc) · 1.27 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
Package main is the main entry point for the application. It requires configuration in a file called app_config.toml.
Example configuration:
[http]
port = 5000
useTLS = false
certFile = ""
keyFile = ""
[log]
loggingEnabled = true
fileName = "testLogs/mockApiHub/default.log"
maxFileDaysAge = 3
formatAsJSON = true
prettyJSON = true
*/
package main
import (
"flag"
"fmt"
"os"
"os/signal"
"github.com/wcsanders1/MockApiHub/config"
"github.com/wcsanders1/MockApiHub/manager"
"github.com/BurntSushi/toml"
)
func main() {
hubFlags := flag.NewFlagSet("hubFlags", flag.ExitOnError)
showVersion := hubFlags.Bool("v", false, "application version")
hubFlags.Parse(os.Args[1:])
hubFlags.Visit(func(f *flag.Flag) {
if f.Name == "v" {
*showVersion = true
fmt.Println("v0.4.0")
}
})
if *showVersion {
return
}
var appConfig config.AppConfig
if _, err := toml.DecodeFile("app_config.toml", &appConfig); err != nil {
fmt.Println(err)
panic(err)
}
mgr, err := manager.NewManager(&appConfig)
if err != nil {
fmt.Println(err)
panic(err)
}
shutdown := make(chan os.Signal)
signal.Notify(shutdown, os.Interrupt)
go func() {
if err := mgr.StartMockAPIHub(); err != nil {
fmt.Println(err)
panic(err)
}
}()
<-shutdown
mgr.StopMockAPIHub()
}