diff --git a/config/conf.go b/config/conf.go index 566c4a3..7ede833 100644 --- a/config/conf.go +++ b/config/conf.go @@ -37,7 +37,7 @@ func GetConfig() *Config { } func SetConfig(mongoUrl string, database string, natsUrl string, lokiUrl string, logLevel string) *Config { - once.Do(func() { + /*once.Do(func() { instance = &Config{ MongoUrl: mongoUrl, MongoDatabase: database, @@ -45,6 +45,11 @@ func SetConfig(mongoUrl string, database string, natsUrl string, lokiUrl string, LokiUrl: lokiUrl, LogLevel: logLevel, } - }) - return instance + })*/ + GetConfig().MongoUrl = mongoUrl + GetConfig().MongoDatabase = database + GetConfig().NATSUrl = natsUrl + GetConfig().LokiUrl = lokiUrl + GetConfig().LogLevel = logLevel + return GetConfig() } diff --git a/entrypoint.go b/entrypoint.go index 5ddd6e2..c40b5c7 100644 --- a/entrypoint.go +++ b/entrypoint.go @@ -124,6 +124,7 @@ func GetLogger() zerolog.Logger { * @return *Config */ func SetConfig(mongoUrl string, database string, natsUrl string, lokiUrl string, logLevel string) *config.Config { + cfg := config.SetConfig(mongoUrl, database, natsUrl, lokiUrl, logLevel) defer func() { if r := recover(); r != nil { tools.UncatchedError = append(tools.UncatchedError, errors.New("Panic recovered in Init : "+fmt.Sprintf("%v", r)+" - "+string(debug.Stack()))) @@ -131,7 +132,6 @@ func SetConfig(mongoUrl string, database string, natsUrl string, lokiUrl string, } }() logs.CreateLogger("main") - cfg := config.SetConfig(mongoUrl, database, natsUrl, lokiUrl, logLevel) mongo.MONGOService.Init(models.GetModelsNames(), config.GetConfig()) // init the mongo service /* Here we will check if the resource model is already stored in the database