diff --git a/Dockerfile b/Dockerfile index 13d16a9..8b2148b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,6 +15,8 @@ ENV MONITORD_PATH = "./oc-monitord" WORKDIR /app +COPY conf/docker_schedulerd.json /etc/oc/schedulerd.json + COPY --from=monitord /app/oc-monitord . COPY --from=builder /app/oc-schedulerd . COPY conf/docker_schedulerd.json /etc/oc/schedulerd.json diff --git a/conf/conf.go b/conf/conf.go index 1258c9a..10984a5 100644 --- a/conf/conf.go +++ b/conf/conf.go @@ -8,20 +8,18 @@ import ( ) type Config struct { - MonitorPath string - OcCatalogUrl string - MongoUrl string - DBName string - Logs string - LokiUrl string - NatsUrl string + MonitorPath string + MongoUrl string + DBName string + Logs string + LokiUrl string + NatsUrl string } var instance *Config var once sync.Once const defaultConfigFile = "/etc/oc/schedulerd.json" -const localConfigFile = "./conf/local_schedulerd.json" func init() { configFile := "" @@ -33,28 +31,18 @@ func init() { logs.Info("Config file found : " + defaultConfigFile) configFile = defaultConfigFile } - l1, err := onion.NewFileLayer(localConfigFile, nil) - if err == nil { - logs.Info("Local config file found " + localConfigFile + ", overriding default file") - configFile = localConfigFile - } - if configFile == "" { + if configFile == "" || l2 == nil { logs.Info("No config file found, using env") o = onion.New(l3) - } else if l1 == nil && l2 == nil { - o = onion.New(l1, l2, l3) - } else if l1 == nil { + } else { 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().OcCatalogUrl = o.GetStringDefault("oc-catalog", "https://localhost:49618") - GetConfig().Logs = o.GetStringDefault("loglevel", "info") - 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().MongoUrl = o.GetStringDefault("mongo_url", "mongodb://127.0.0.1:27017") - GetConfig().DBName = o.GetStringDefault("database_name", "DC_myDC") + GetConfig().Logs = o.GetStringDefault("LOG_LEVEL", "info") + 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().MongoUrl = o.GetStringDefault("MONGO_URL", "mongodb://127.0.0.1:27017") + GetConfig().DBName = o.GetStringDefault("MONGO_DATABASE", "DC_myDC") } diff --git a/conf/docker_schedulerd.json b/conf/docker_schedulerd.json index 1122afb..0cbd3d1 100644 --- a/conf/docker_schedulerd.json +++ b/conf/docker_schedulerd.json @@ -1,4 +1,6 @@ { - "oc-catalog" : "http://oc-catalog:49618/", - "loki_url" : "http://192.168.1.18:3100" + "LOKI_URL" : "http://loki:3100", + "MONGO_URL":"mongodb://mongo:27017/", + "MONGO_DATABASE":"DC_myDC", + "NATS_URL": "nats://nats:4222" } \ No newline at end of file diff --git a/conf/local_scheduler.json b/conf/local_scheduler.json deleted file mode 100644 index 0b75743..0000000 --- a/conf/local_scheduler.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "oc-catalog" : "http://localhost:49618/", - "logs" : "", - "mongo_url": "mongodb://127.0.0.1:27017" -} \ No newline at end of file diff --git a/daemons/schedule_manager.go b/daemons/schedule_manager.go index 7ed9672..f0fb5d7 100644 --- a/daemons/schedule_manager.go +++ b/daemons/schedule_manager.go @@ -3,6 +3,7 @@ package daemons import ( "encoding/json" "fmt" + "oc-schedulerd/conf" "sync" "time" @@ -72,7 +73,7 @@ type ScheduleManager struct { // on workflows' scheduling. Messages must contain // workflow execution ID, to allow retrieval of execution infos func (s *ScheduleManager) ListenForWorkflowSubmissions() { - nc, err := nats.Connect(nats.DefaultURL) + nc, err := nats.Connect(conf.GetConfig().NatsUrl) if err != nil { s.Logger.Error().Msg("Could not connect to NATS") return diff --git a/docker-compose.tools.yml b/docker-compose.tools.yml new file mode 100644 index 0000000..e8fd996 --- /dev/null +++ b/docker-compose.tools.yml @@ -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 \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index e8fd996..0e05df0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,39 +1,16 @@ version: '3.4' services: - nats: - image: 'nats:latest' - container_name: nats + oc-schedulerd: + environment: + - MONGO_DATABASE=DC_myDC + image: 'oc-schedulerd:latest' ports: - - 4222:4222 - command: - - "--debug" + - 9001:8080 + container_name: oc-schedulerd 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 \ No newline at end of file diff --git a/oc-scheduler b/oc-schedulerd similarity index 70% rename from oc-scheduler rename to oc-schedulerd index 64f986b..c836e7a 100755 Binary files a/oc-scheduler and b/oc-schedulerd differ