oc-schedulerd/daemons/execute_monitor_local.go
2024-08-09 18:44:33 +02:00

48 lines
1012 B
Go

package daemons
import (
"fmt"
"oc-scheduler/logger"
"os/exec"
)
type LocalMonitor struct{
LokiURL string
KubeURL string
WorkflowName string
}
func (lm *LocalMonitor) LaunchLocalMonitor (){
if (lm.LokiURL == "" || lm.KubeURL == "" || lm.WorkflowName == ""){
logger.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 (){
// kube_url := ""
cmd := exec.Command("../oc-monitor/oc-monitor", "-w",lm.WorkflowName, "-u", lm.LokiURL)
// cmd_ls := exec.Command("ls", "../oc-monitor")
output, err := cmd.CombinedOutput()
// output, err := cmd_ls.CombinedOutput()
fmt.Println(string(output))
if err !=nil {
logger.Logger.Error().Msg("Could not start oc-monitor for " + lm.WorkflowName + " : " + err.Error())
}
}
func (lm *LocalMonitor) execRemoteKube (){
}
func (lm *LocalMonitor) todo (){
}