This commit is contained in:
mr 2024-08-20 09:23:05 +02:00
parent e5cfd6f4fb
commit 825c18b6d6
8 changed files with 66 additions and 62 deletions

View File

@ -15,6 +15,8 @@ ENV MONITORD_PATH = "./oc-monitord"
WORKDIR /app WORKDIR /app
COPY conf/docker_schedulerd.json /etc/oc/schedulerd.json
COPY --from=monitord /app/oc-monitord . COPY --from=monitord /app/oc-monitord .
COPY --from=builder /app/oc-schedulerd . COPY --from=builder /app/oc-schedulerd .
COPY conf/docker_schedulerd.json /etc/oc/schedulerd.json COPY conf/docker_schedulerd.json /etc/oc/schedulerd.json

View File

@ -8,20 +8,18 @@ import (
) )
type Config struct { type Config struct {
MonitorPath string MonitorPath string
OcCatalogUrl string MongoUrl string
MongoUrl string DBName string
DBName string Logs string
Logs string LokiUrl string
LokiUrl string NatsUrl string
NatsUrl string
} }
var instance *Config var instance *Config
var once sync.Once var once sync.Once
const defaultConfigFile = "/etc/oc/schedulerd.json" const defaultConfigFile = "/etc/oc/schedulerd.json"
const localConfigFile = "./conf/local_schedulerd.json"
func init() { func init() {
configFile := "" configFile := ""
@ -33,28 +31,18 @@ func init() {
logs.Info("Config file found : " + defaultConfigFile) logs.Info("Config file found : " + defaultConfigFile)
configFile = defaultConfigFile configFile = defaultConfigFile
} }
l1, err := onion.NewFileLayer(localConfigFile, nil) if configFile == "" || l2 == nil {
if err == nil {
logs.Info("Local config file found " + localConfigFile + ", overriding default file")
configFile = localConfigFile
}
if configFile == "" {
logs.Info("No config file found, using env") logs.Info("No config file found, using env")
o = onion.New(l3) o = onion.New(l3)
} else if l1 == nil && l2 == nil { } else {
o = onion.New(l1, l2, l3)
} else if l1 == nil {
o = onion.New(l2, l3) o = onion.New(l2, l3)
} else if l2 == nil {
o = onion.New(l1, l3)
} }
GetConfig().MonitorPath = o.GetStringDefault("MONITORD_PATH", "../oc-monitord/oc-monitord") GetConfig().MonitorPath = o.GetStringDefault("MONITORD_PATH", "../oc-monitord/oc-monitord")
GetConfig().OcCatalogUrl = o.GetStringDefault("oc-catalog", "https://localhost:49618") GetConfig().Logs = o.GetStringDefault("LOG_LEVEL", "info")
GetConfig().Logs = o.GetStringDefault("loglevel", "info") GetConfig().LokiUrl = o.GetStringDefault("LOKI_URL", "http://127.0.0.1:3100")
GetConfig().LokiUrl = o.GetStringDefault("loki_url", "http://127.0.0.1:3100") GetConfig().NatsUrl = o.GetStringDefault("NATS_URL", "http://127.0.0.1:4222")
GetConfig().NatsUrl = o.GetStringDefault("nats_url", "http://127.0.0.1:4222") GetConfig().MongoUrl = o.GetStringDefault("MONGO_URL", "mongodb://127.0.0.1:27017")
GetConfig().MongoUrl = o.GetStringDefault("mongo_url", "mongodb://127.0.0.1:27017") GetConfig().DBName = o.GetStringDefault("MONGO_DATABASE", "DC_myDC")
GetConfig().DBName = o.GetStringDefault("database_name", "DC_myDC")
} }

View File

@ -1,4 +1,6 @@
{ {
"oc-catalog" : "http://oc-catalog:49618/", "LOKI_URL" : "http://loki:3100",
"loki_url" : "http://192.168.1.18:3100" "MONGO_URL":"mongodb://mongo:27017/",
"MONGO_DATABASE":"DC_myDC",
"NATS_URL": "nats://nats:4222"
} }

View File

@ -1,5 +0,0 @@
{
"oc-catalog" : "http://localhost:49618/",
"logs" : "",
"mongo_url": "mongodb://127.0.0.1:27017"
}

View File

@ -3,6 +3,7 @@ package daemons
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"oc-schedulerd/conf"
"sync" "sync"
"time" "time"
@ -72,7 +73,7 @@ type ScheduleManager struct {
// on workflows' scheduling. Messages must contain // on workflows' scheduling. Messages must contain
// workflow execution ID, to allow retrieval of execution infos // workflow execution ID, to allow retrieval of execution infos
func (s *ScheduleManager) ListenForWorkflowSubmissions() { func (s *ScheduleManager) ListenForWorkflowSubmissions() {
nc, err := nats.Connect(nats.DefaultURL) nc, err := nats.Connect(conf.GetConfig().NatsUrl)
if err != nil { if err != nil {
s.Logger.Error().Msg("Could not connect to NATS") s.Logger.Error().Msg("Could not connect to NATS")
return return

39
docker-compose.tools.yml Normal file
View File

@ -0,0 +1,39 @@
version: '3.4'
services:
nats:
image: 'nats:latest'
container_name: nats
ports:
- 4222:4222
command:
- "--debug"
networks:
- scheduler
- catalog
loki:
image: 'grafana/loki'
container_name: loki
ports :
- "3100:3100"
networks:
- scheduler
grafana:
image: 'grafana/grafana'
container_name: grafana
ports:
- '3000:3000'
networks:
- scheduler
volumes:
- ./conf/grafana_data_source.yml:/etc/grafana/provisioning/datasources/datasource.yml
environment:
- GF_SECURITY_ADMIN_PASSWORD=pfnirt # Change this to anything but admin to not have a password change page at startup
- GF_SECURITY_ADMIN_USER=admin
- GF_SECURITY_DISABLE_INITIAL_ADMIN_PASSWORD_CHANGE=true
networks:
scheduler:
external: true
catalog:
external: true

View File

@ -1,39 +1,16 @@
version: '3.4' version: '3.4'
services: services:
nats: oc-schedulerd:
image: 'nats:latest' environment:
container_name: nats - MONGO_DATABASE=DC_myDC
image: 'oc-schedulerd:latest'
ports: ports:
- 4222:4222 - 9001:8080
command: container_name: oc-schedulerd
- "--debug"
networks: networks:
- scheduler
- catalog - catalog
loki:
image: 'grafana/loki'
container_name: loki
ports :
- "3100:3100"
networks:
- scheduler
grafana:
image: 'grafana/grafana'
container_name: grafana
ports:
- '3000:3000'
networks:
- scheduler
volumes:
- ./conf/grafana_data_source.yml:/etc/grafana/provisioning/datasources/datasource.yml
environment:
- GF_SECURITY_ADMIN_PASSWORD=pfnirt # Change this to anything but admin to not have a password change page at startup
- GF_SECURITY_ADMIN_USER=admin
- GF_SECURITY_DISABLE_INITIAL_ADMIN_PASSWORD_CHANGE=true
networks: networks:
scheduler:
external: true
catalog: catalog:
external: true external: true

Binary file not shown.