adapt to services
This commit is contained in:
14
main.go
14
main.go
@@ -28,6 +28,13 @@ import (
|
||||
"github.com/rs/zerolog"
|
||||
)
|
||||
|
||||
// Command-line args:
|
||||
// - url: Loki URL (default: "http://127.0.0.1:3100")
|
||||
// - execution: Workflow Execution ID (required) to identify the current execution, allows to retrieve Workflow
|
||||
// - mongo: MongoDB URL (default: "mongodb://127.0.0.1:27017")
|
||||
// - db: MongoDB database name (default: "DC_myDC")
|
||||
// - timeout: Execution timeout (default: -1)
|
||||
|
||||
var logger zerolog.Logger
|
||||
var wf_logger zerolog.Logger
|
||||
var pods_logger zerolog.Logger
|
||||
@@ -40,6 +47,8 @@ const localConfigFile = "./conf/local_ocmonitord_conf.json"
|
||||
|
||||
func main() {
|
||||
|
||||
os.Setenv("test_service","true") // Only for service demo, delete before merging on main
|
||||
|
||||
monitorLocal = false
|
||||
// Test if monitor is launched outside (with parameters) or in a k8s environment (env variables sets)
|
||||
if os.Getenv("KUBERNETES_SERVICE_HOST") == "" {
|
||||
@@ -216,7 +225,7 @@ func setConf(is_k8s bool, o *onion.Onion, parser *argparse.Parser) {
|
||||
tools.SetConfig(mongo, db, "")
|
||||
} else {
|
||||
url := parser.String("u", "url", &argparse.Options{Required: true, Default: "http://127.0.0.1:3100", Help: "Url to the Loki database logs will be sent to"})
|
||||
workflow := parser.String("w", "workflow", &argparse.Options{Required: true, Help: "Execution ID of the workflow to request from oc-catalog API"})
|
||||
execution := parser.String("e", "execution", &argparse.Options{Required: true, Help: "Execution ID of the workflow to request from oc-catalog API"})
|
||||
mongo := parser.String("m", "mongo", &argparse.Options{Required: true, Default: "mongodb://127.0.0.1:27017", Help: "URL to reach the MongoDB"})
|
||||
db := parser.String("d", "database", &argparse.Options{Required: true, Default: "DC_myDC", Help: "Name of the database to query in MongoDB"})
|
||||
timeout := parser.Int("t", "timeout", &argparse.Options{Required: false, Default: -1, Help: "Timeout for the execution of the workflow"})
|
||||
@@ -227,12 +236,13 @@ func setConf(is_k8s bool, o *onion.Onion, parser *argparse.Parser) {
|
||||
}
|
||||
conf.GetConfig().LokiURL = *url
|
||||
conf.GetConfig().Timeout = *timeout
|
||||
conf.GetConfig().ExecutionID = *workflow
|
||||
conf.GetConfig().ExecutionID = *execution
|
||||
tools.SetConfig(*mongo, *db, "")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
func initOnion(o *onion.Onion) *onion.Onion {
|
||||
logger = logs.CreateLogger("oc-monitord", "")
|
||||
configFile := ""
|
||||
|
||||
Reference in New Issue
Block a user