-
Notifications
You must be signed in to change notification settings - Fork 28
/
main.go
62 lines (54 loc) · 1.19 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
package main
import (
"os"
"strings"
"github.com/sdslabs/gasper/configs"
"github.com/sdslabs/gasper/lib/utils"
"github.com/sdslabs/gasper/services/appmaker"
"github.com/sdslabs/gasper/services/gendns"
"github.com/sdslabs/gasper/services/genproxy"
"github.com/sdslabs/gasper/services/master"
"golang.org/x/sync/errgroup"
)
func initMaster() {
go master.ScheduleServiceExposure()
if configs.ServiceConfig.Master.Deploy {
go master.ScheduleCleanup()
}
}
func initAppMaker() {
if configs.ServiceConfig.AppMaker.Deploy {
go appmaker.ScheduleMetricsCollection()
go appmaker.ScheduleHealthCheck()
}
}
func initGenDNS() {
if configs.ServiceConfig.GenDNS.Deploy {
go gendns.ScheduleUpdate()
}
}
func initGenProxy() {
if configs.ServiceConfig.GenProxy.Deploy {
go genproxy.ScheduleUpdate()
}
}
func initServices() {
var g errgroup.Group
for service, launcher := range launcherBindings {
if launcher.Deploy {
g.Go(launcher.Start)
utils.LogInfo("Main-1", "%s Service Active", strings.Title(service))
}
}
if err := g.Wait(); err != nil {
utils.LogError("Main-2", err)
os.Exit(1)
}
}
func main() {
initMaster()
initAppMaker()
initGenDNS()
initGenProxy()
initServices()
}