This repository has been archived by the owner on Jun 25, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.go
69 lines (54 loc) · 1.81 KB
/
app.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
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"go-mesos-framework-kafka/api"
"go-mesos-framework-kafka/mesos"
mesosproto "go-mesos-framework-kafka/proto"
cfg "go-mesos-framework-kafka/types"
util "github.com/AVENTER-UG/util/util"
"github.com/Showmax/go-fqdn"
"github.com/sirupsen/logrus"
)
var MinVersion string
func main() {
util.SetLogging(config.LogLevel, config.EnableSyslog, config.AppName)
logrus.Println(config.AppName + " build " + MinVersion)
hostname := fqdn.Get()
listen := fmt.Sprintf(":%s", config.FrameworkPort)
logrus.Info(hostname)
failoverTimeout := 5000.0
checkpoint := true
webuiurl := fmt.Sprintf("http://%s%s", hostname, listen)
config.FrameworkInfoFile = fmt.Sprintf("%s/%s", config.FrameworkInfoFilePath, "framework.json")
config.CommandChan = make(chan cfg.Command, 100)
config.Hostname = hostname
config.Listen = listen
config.State = map[string]cfg.State{}
config.FrameworkInfo.User = &config.FrameworkUser
config.FrameworkInfo.Name = &config.FrameworkName
config.FrameworkInfo.Hostname = &hostname
config.FrameworkInfo.WebuiUrl = &webuiurl
config.FrameworkInfo.FailoverTimeout = &failoverTimeout
config.FrameworkInfo.Checkpoint = &checkpoint
config.FrameworkInfo.Principal = &config.Principal
config.FrameworkInfo.Role = &config.FrameworkRole
config.FrameworkInfo.Capabilities = []*mesosproto.FrameworkInfo_Capability{
{Type: mesosproto.FrameworkInfo_Capability_RESERVATION_REFINEMENT.Enum()},
}
// Load the old state if its exist
frameworkJSON, err := ioutil.ReadFile(config.FrameworkInfoFile)
if err == nil {
json.Unmarshal([]byte(frameworkJSON), &config)
mesos.Reconcile()
}
mesos.SetConfig(&config)
api.SetConfig(&config)
http.Handle("/", api.Commands())
go func() {
http.ListenAndServe(listen, nil)
}()
logrus.Fatal(mesos.Subscribe())
}