From e076c04edb0e2d93e86060300cddcb04eb319405 Mon Sep 17 00:00:00 2001 From: Mayuresh Gaitonde Date: Mon, 5 Nov 2018 14:28:53 -0800 Subject: [PATCH] add apps from config --- config/config.go | 6 ++++++ controller/monitor.go | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/config/config.go b/config/config.go index 0b4a83e..aea31a5 100644 --- a/config/config.go +++ b/config/config.go @@ -23,6 +23,12 @@ type Config struct { Communities []string Origin string } + Apps []struct { + Name string + Vip string + Monitors []string + Nats []string + } } func GetConfig(file string) *Config { diff --git a/controller/monitor.go b/controller/monitor.go index 03028ff..3969a46 100644 --- a/controller/monitor.go +++ b/controller/monitor.go @@ -95,6 +95,15 @@ func NewMonitor(config *c.Config) *MonitorMgr { config.Agent.CleanupTimer = defaultCleanupTimer } mon.config = config + // add apps defined in config + for _, a := range config.Apps { + app, err := NewApp(a.Name, a.Vip, a.Monitors, a.Nats) + if err != nil { + glog.Errorf("Failed to add configured app %s: %v", a.Name, err) + continue + } + mon.Add(app) + } return mon }