2023-02-26 22:26:09 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
2023-03-25 20:15:00 +00:00
|
|
|
"github.com/azukaar/cosmos-server/src/utils"
|
2023-02-26 22:26:09 +00:00
|
|
|
)
|
|
|
|
|
2023-03-10 20:59:56 +00:00
|
|
|
func LoadConfig() utils.Config {
|
2023-04-27 18:29:26 +00:00
|
|
|
config := utils.ReadConfigFromFile()
|
2023-02-26 22:26:09 +00:00
|
|
|
|
2023-04-07 14:04:42 +00:00
|
|
|
// check if config is valid
|
|
|
|
utils.Log("Validating config file...")
|
2023-04-27 18:29:26 +00:00
|
|
|
err := utils.Validate.Struct(config)
|
2023-04-07 14:04:42 +00:00
|
|
|
if err != nil {
|
|
|
|
utils.Fatal("Reading Config File: " + err.Error(), err)
|
|
|
|
}
|
|
|
|
|
2023-03-10 20:59:56 +00:00
|
|
|
utils.LoadBaseMainConfig(config)
|
2023-04-11 17:33:49 +00:00
|
|
|
|
|
|
|
configJson, _ := json.MarshalIndent(config, "", " ")
|
|
|
|
utils.Debug("Loaded Configuration " + (string)(configJson))
|
2023-03-10 20:59:56 +00:00
|
|
|
|
2023-02-26 22:26:09 +00:00
|
|
|
return config
|
|
|
|
}
|