forked from allegro/marathon-consul
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
46 lines (35 loc) · 1.05 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
package main
import (
"net/http"
log "github.com/Sirupsen/logrus"
"github.com/allegro/marathon-consul/config"
service "github.com/allegro/marathon-consul/consul"
"github.com/allegro/marathon-consul/marathon"
"github.com/allegro/marathon-consul/metrics"
"github.com/allegro/marathon-consul/sync"
"github.com/allegro/marathon-consul/web"
)
var VERSION string
func main() {
log.WithField("Version", VERSION).Info("Starting marathon-consul")
config, err := config.New()
if err != nil {
log.Fatal(err.Error())
}
err = metrics.Init(config.Metrics)
if err != nil {
log.Fatal(err.Error())
}
service := service.New(config.Consul)
remote, err := marathon.New(config.Marathon)
if err != nil {
log.Fatal(err.Error())
}
sync := sync.New(config.Sync, remote, service)
go sync.StartSyncServicesJob()
// set up routes
http.HandleFunc("/health", web.HealthHandler)
http.HandleFunc("/events", web.NewEventHandler(service, remote).Handle)
log.WithField("Port", config.Web.Listen).Info("Listening")
log.Fatal(http.ListenAndServe(config.Web.Listen, nil))
}