42 lines
955 B
Go
42 lines
955 B
Go
package daemons
|
|
|
|
import (
|
|
"oc-schedulerd/conf"
|
|
"os/exec"
|
|
|
|
"github.com/rs/zerolog"
|
|
)
|
|
|
|
type LocalMonitor struct {
|
|
LokiURL string
|
|
KubeURL string
|
|
WorkflowName string
|
|
Logger zerolog.Logger
|
|
}
|
|
|
|
func (lm *LocalMonitor) LaunchLocalMonitor() {
|
|
if lm.LokiURL == "" || lm.KubeURL == "" || lm.WorkflowName == "" {
|
|
lm.Logger.Error().Msg("Missing parameter in LocalMonitor")
|
|
}
|
|
|
|
// For dev purposes, in prod KubeURL must be a kube API's URL
|
|
if lm.KubeURL == "localhost" {
|
|
lm.execLocalKube()
|
|
} else {
|
|
lm.execRemoteKube()
|
|
}
|
|
}
|
|
|
|
func (lm *LocalMonitor) execLocalKube() {
|
|
cmd := exec.Command(conf.GetConfig().MonitorPath, "-w", lm.WorkflowName, "-u", lm.LokiURL, "-m", conf.GetConfig().MongoUrl, "-d", conf.GetConfig().DBName)
|
|
err := cmd.Start()
|
|
if err != nil {
|
|
lm.Logger.Error().Msg("Could not start oc-monitor for " + lm.WorkflowName + " : " + err.Error())
|
|
}
|
|
}
|
|
|
|
// TODO : implement this
|
|
func (lm *LocalMonitor) execRemoteKube() {
|
|
|
|
}
|