This repository has been archived by the owner on Mar 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
81 lines (65 loc) · 1.92 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
75
76
77
78
79
80
81
package main
import (
"flag"
"fmt"
"kevinkamps/registrar/configuration"
"kevinkamps/registrar/monitor"
"kevinkamps/registrar/monitor/docker"
"kevinkamps/registrar/monitor/static"
"kevinkamps/registrar/provider/aws"
"kevinkamps/registrar/provider/ifconfig"
"kevinkamps/registrar/provider/local"
"kevinkamps/registrar/registry"
"kevinkamps/registrar/registry/consul"
"os"
"sync"
)
var version string
func main() {
var configurations []configuration.Configuration
/**
Monitors
*/
dockerConfiguration := docker.NewDockerConfiguration()
configurations = append(configurations, dockerConfiguration)
staticConfiguration := static.NewStaticConfiguration()
configurations = append(configurations, staticConfiguration)
/**
Providers
*/
networkProviderConfiguration := local.NewNetworkProviderConfiguration()
configurations = append(configurations, networkProviderConfiguration)
ifconfigProviderConfiguration := ifconfig.NewIfconfigProviderConfiguration()
configurations = append(configurations, ifconfigProviderConfiguration)
awsProviderConfiguration := aws.NewAwsProviderConfiguration()
configurations = append(configurations, awsProviderConfiguration)
/**
registrar
*/
consulConfiguration := consul.NewConsulConfiguration()
configurations = append(configurations, consulConfiguration)
showVersion := flag.Bool("version", false, "Prints the version of the application and exits")
flag.Parse()
if *showVersion {
fmt.Println(version)
os.Exit(0)
}
for _, configuration := range configurations {
configuration.Parse()
}
var wg sync.WaitGroup
rs := registry.NewRegistryService(consulConfiguration, networkProviderConfiguration, ifconfigProviderConfiguration, awsProviderConfiguration)
ms := monitor.NewMonitorService(rs, dockerConfiguration, staticConfiguration)
wg.Add(1)
go func() {
rs.Start()
wg.Done()
}()
wg.Add(1)
go func() {
ms.Start()
wg.Done()
}()
wg.Wait()
fmt.Println("Shutting Down")
}