From 0f6213cd14c1b75846664328182e745b09e4b307 Mon Sep 17 00:00:00 2001 From: pb Date: Thu, 17 Apr 2025 19:58:19 +0200 Subject: [PATCH] Added some test and logging on the path to execute monitord --- main.go | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 7ba18c6..9b0a36f 100644 --- a/main.go +++ b/main.go @@ -4,13 +4,14 @@ import ( "fmt" "oc-schedulerd/conf" "oc-schedulerd/daemons" + "os" oclib "cloud.o-forge.io/core/oc-lib" ) func main() { - oclib.InitDaemon("oc-schedulerd") + l := oclib.GetLogger() o := oclib.GetConfLoader() c := oclib.SetConfig( @@ -20,6 +21,7 @@ func main() { o.GetStringDefault("LOKI_URL", ""), o.GetStringDefault("LOG_LEVEL", "info"), ) + conf.GetConfig().DBName = c.MongoDatabase conf.GetConfig().MongoUrl = c.MongoUrl conf.GetConfig().NatsUrl = c.NATSUrl @@ -32,6 +34,22 @@ func main() { conf.GetConfig().KubeCert = o.GetStringDefault("KUBE_CERT", "") conf.GetConfig().KubeData = o.GetStringDefault("KUBE_DATA", "") + // Test if oc-monitor binary is reachable + // For local executions + if _, err := os.Stat("../oc-monitord/oc-monitord"); err == nil { + conf.GetConfig().MonitorPath = "../oc-monitord/oc-monitord" + } + // For container executions + if _, err := os.Stat("/usr/bin/oc-monitord"); conf.GetConfig().MonitorPath == "" && err == nil { + conf.GetConfig().MonitorPath = "/usr/bin/oc-monitord" + } + + if conf.GetConfig().MonitorPath == "" { + l.Fatal().Msg("Could not find oc-monitord binary") + } + + l.Info().Msg("oc-monitord binary at " + conf.GetConfig().MonitorPath ) + sch_mngr := daemons.ScheduleManager{Logger: oclib.GetLogger()} exe_mngr := daemons.ExecutionManager{}