-
Notifications
You must be signed in to change notification settings - Fork 80
Expand file tree
/
Copy pathmain.go
More file actions
71 lines (58 loc) · 1.65 KB
/
main.go
File metadata and controls
71 lines (58 loc) · 1.65 KB
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
70
71
package main
import (
"context"
"fmt"
"os"
"os/signal"
"syscall"
"github.com/abahmed/kwatch/client"
"github.com/abahmed/kwatch/config"
"github.com/abahmed/kwatch/constant"
"github.com/abahmed/kwatch/handler"
"github.com/abahmed/kwatch/health"
"github.com/abahmed/kwatch/pvcmonitor"
"github.com/abahmed/kwatch/startup"
"github.com/abahmed/kwatch/storage/memory"
"github.com/abahmed/kwatch/upgrader"
"github.com/abahmed/kwatch/util"
"github.com/abahmed/kwatch/version"
"github.com/abahmed/kwatch/watcher"
"github.com/sirupsen/logrus"
)
func main() {
cfg, err := config.LoadConfig()
if err != nil {
logrus.Fatalf("failed to load config: %s", err.Error())
}
util.SetLogFormatter(cfg.App.LogFormatter)
logrus.Info(fmt.Sprintf(constant.WelcomeMsg, version.Short()))
k8sClient := client.Create(&cfg.App)
sm := startup.NewStartupManager(
k8sClient,
util.GetNamespace(),
&cfg.Telemetry,
cfg.Alert,
&cfg.App,
)
sm.HandleStartup(context.Background())
healthServer := health.NewHealthServer(cfg.HealthCheck)
healthServer.Start(context.Background())
upgrader := upgrader.NewUpgrader(&cfg.Upgrader, sm.GetAlertManager(), sm.GetStateManager())
go upgrader.CheckUpdates()
pvcMonitor := pvcmonitor.NewPvcMonitor(k8sClient, &cfg.PvcMonitor, sm.GetAlertManager())
go pvcMonitor.Start()
h := handler.NewHandler(
k8sClient,
cfg,
memory.NewMemory(),
sm.GetAlertManager(),
)
ctx := context.Background()
watcher.Start(ctx, k8sClient, cfg, h)
sigCh := make(chan os.Signal, 1)
signal.Notify(sigCh, syscall.SIGINT, syscall.SIGTERM)
<-sigCh
logrus.Info("shutting down gracefully...")
healthServer.Stop(context.Background())
os.Exit(0)
}