-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
51 lines (41 loc) · 1.34 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
package main
import (
"encoding/json"
"fmt"
"github.com/rabobank/scheduler-service-broker/conf"
"github.com/rabobank/scheduler-service-broker/cron"
"github.com/rabobank/scheduler-service-broker/db"
"github.com/rabobank/scheduler-service-broker/server"
"github.com/rabobank/scheduler-service-broker/util"
"os"
)
func main() {
fmt.Printf("scheduler-service-broker starting, version:%s, commit:%s\n", conf.VERSION, conf.COMMIT)
conf.EnvironmentComplete()
initialize()
cron.StartRunner()
cron.StartHousekeeping()
server.StartServer()
}
// initialize scheduler-service-broker:
func initialize() {
catalogFile := fmt.Sprintf("%s/catalog.json", conf.CatalogDir)
if file, err := os.ReadFile(catalogFile); err != nil {
fmt.Printf("failed reading catalog file %s: %s\n", catalogFile, err)
os.Exit(8)
} else {
if err = json.Unmarshal(file, &conf.Catalog); err != nil {
fmt.Printf("failed unmarshalling catalog file %s, error: %s\n", catalogFile, err)
os.Exit(8)
} else {
// login to cf and get a client handle
util.CfClient = *util.GetCFClient()
// test if the DB can be opened
database := db.GetDB()
if err = database.Close(); err != nil {
fmt.Printf("failed to open database %s:%s\n", fmt.Sprintf("%s:%s@(%s)/%s?parseTime=true", conf.DBUser, "<redacted>", conf.DBHost, conf.DBName), err)
os.Exit(8)
}
}
}
}