|
|
@@ -6,11 +6,18 @@ import (
|
|
|
"git.sxidc.com/go-tools/utils/strutils"
|
|
|
"git.sxidc.com/service-supports/fslog"
|
|
|
"git.sxidc.com/service-supports/scm-sdk"
|
|
|
+ "gopkg.in/yaml.v3"
|
|
|
"os"
|
|
|
)
|
|
|
|
|
|
type Config struct {
|
|
|
ApplicationConfig application.Config
|
|
|
+ ServicesConfig ServicesConfig `yaml:"services"`
|
|
|
+}
|
|
|
+
|
|
|
+type ServicesConfig struct {
|
|
|
+ TimeoutSec int64 `yaml:"timeout_sec"`
|
|
|
+ ExampleBaseUrl string `yaml:"example_base_url"`
|
|
|
}
|
|
|
|
|
|
var conf Config
|
|
|
@@ -46,6 +53,11 @@ func initConfigFromSCM() {
|
|
|
|
|
|
conf.ApplicationConfig = applicationConfig
|
|
|
|
|
|
+ err = yaml.Unmarshal([]byte(info.Content), &conf)
|
|
|
+ if err != nil {
|
|
|
+ panic(err)
|
|
|
+ }
|
|
|
+
|
|
|
fslog.Info("Load config from scm finish")
|
|
|
}
|
|
|
|
|
|
@@ -58,6 +70,16 @@ func initConfigFromConfigFile() {
|
|
|
|
|
|
conf.ApplicationConfig = applicationConfig
|
|
|
|
|
|
+ yamlBytes, err := os.ReadFile(configFilePath)
|
|
|
+ if err != nil {
|
|
|
+ panic(err)
|
|
|
+ }
|
|
|
+
|
|
|
+ err = yaml.Unmarshal(yamlBytes, &conf)
|
|
|
+ if err != nil {
|
|
|
+ panic(err)
|
|
|
+ }
|
|
|
+
|
|
|
fmt.Println("Load config file finish")
|
|
|
}
|
|
|
|