-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
59 lines (41 loc) · 1.03 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
package main
import (
"net/http"
"os"
"github.com/gorilla/mux"
log "github.com/sirupsen/logrus"
)
func init() {
// Log as JSON instead of the default ASCII formatter.
log.SetFormatter(&log.JSONFormatter{})
// Output to stdout instead of the default stderr
// Can be any io.Writer, see below for File example
log.SetOutput(os.Stdout)
}
var config map[string]string
var ready bool
func main() {
//readiness probe false by default
ready = false
// Parse /config/service.yaml
c, err := ConfigParse()
if err != nil {
log.Fatal("Can't parse config")
}
// Create mux router
r := mux.NewRouter()
config = make(map[string]string)
// Register all the custom roles to the services
for _, service := range c.Services {
r.HandleFunc(service.Path, ServiceHandler)
config[service.Path] = service.Name
}
// Register default route
r.HandleFunc("/", RootHandler)
// Register ready route
r.HandleFunc("/ready", ReadyHandler)
// Start the sync daemon
go SyncDaemon()
// Start http server
http.ListenAndServe(":8080", r)
}