perf ⚡ 优化配置文件加载

This commit is contained in:
linwenxiang committed 2021-06-09 16:30:24 +08:00
1 parent b8ab38308d
commit f35a808975
4 files changed
+5 -10

No files matched your search

+1 -6
View File
@@ -58,8 +58,7 @@ func setup() {
// 注入配置扩展项
config.ExtendConfig = &ext.ExtConfig
//1. 读取配置
config.Setup(file.NewSource, file.WithPath(configYml))
go config.Watch()
config.Setup(file.NewSource(file.WithPath(configYml)))
//2. 设置日志
sdk.Runtime.SetLogger(
logger.SetupLogger(
@@ -70,8 +69,6 @@ func setup() {
//3. 初始化数据库链接
database.Setup()
//list := sdk.Runtime.GetDb()
//list["*"]
//4. 设置缓存
cacheAdapter, err := config.CacheConfig.Setup()
if err != nil {
@@ -113,8 +110,6 @@ func setup() {
}
func run() error {
defer config.Stop()
if config.ApplicationConfig.Mode == pkg.ModeProd.String() {
gin.SetMode(gin.ReleaseMode)
}
+1 -1
View File
@@ -27,7 +27,7 @@ func init() {
}
func run() {
config.Setup(file.NewSource, file.WithPath(configYml))
config.Setup(file.NewSource(file.WithPath(configYml)))
application, errs := json.MarshalIndent(config.ApplicationConfig, "", " ") //转换成JSON返回的是byte[]
if errs != nil {
+1 -1
View File
@@ -49,7 +49,7 @@ func run() {
if !generate {
fmt.Println(`start init`)
//1. 读取配置
config.Setup(file.NewSource, file.WithPath(configYml))
config.Setup(file.NewSource(file.WithPath(configYml)))
//2. 设置日志
sdk.Runtime.SetLogger(
logger.SetupLogger(
+2 -2
View File
@@ -9,8 +9,8 @@ require (
github.com/bytedance/go-tagexpr/v2 v2.7.10
github.com/casbin/casbin/v2 v2.25.1
github.com/gin-gonic/gin v1.7.1
github.com/go-admin-team/go-admin-core v1.3.5-rc.3.0.20210609055649-3acdd6f47eab
github.com/go-admin-team/go-admin-core/sdk v1.3.0-rc.3.0.20210609055649-3acdd6f47eab
github.com/go-admin-team/go-admin-core v1.3.5-rc.3.0.20210609062350-5aeb6bd49b09
github.com/go-admin-team/go-admin-core/sdk v1.3.0-rc.3.0.20210609082125-a317acc34456
github.com/google/uuid v1.2.0
github.com/mssola/user_agent v0.5.2
github.com/opentracing/opentracing-go v1.1.0