perf ⚡ 优化配置文件加载
This commit is contained in:
1 parent
b8ab38308d
commit
f35a808975
4 files changed
+5
-10
No files matched your search
+1
-6
@@ -58,8 +58,7 @@ func setup() {
|
|||||||
// 注入配置扩展项
|
// 注入配置扩展项
|
||||||
config.ExtendConfig = &ext.ExtConfig
|
config.ExtendConfig = &ext.ExtConfig
|
||||||
//1. 读取配置
|
//1. 读取配置
|
||||||
config.Setup(file.NewSource, file.WithPath(configYml))
|
config.Setup(file.NewSource(file.WithPath(configYml)))
|
||||||
go config.Watch()
|
|
||||||
//2. 设置日志
|
//2. 设置日志
|
||||||
sdk.Runtime.SetLogger(
|
sdk.Runtime.SetLogger(
|
||||||
logger.SetupLogger(
|
logger.SetupLogger(
|
||||||
@@ -70,8 +69,6 @@ func setup() {
|
|||||||
//3. 初始化数据库链接
|
//3. 初始化数据库链接
|
||||||
database.Setup()
|
database.Setup()
|
||||||
|
|
||||||
//list := sdk.Runtime.GetDb()
|
|
||||||
//list["*"]
|
|
||||||
//4. 设置缓存
|
//4. 设置缓存
|
||||||
cacheAdapter, err := config.CacheConfig.Setup()
|
cacheAdapter, err := config.CacheConfig.Setup()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -113,8 +110,6 @@ func setup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func run() error {
|
func run() error {
|
||||||
defer config.Stop()
|
|
||||||
|
|
||||||
if config.ApplicationConfig.Mode == pkg.ModeProd.String() {
|
if config.ApplicationConfig.Mode == pkg.ModeProd.String() {
|
||||||
gin.SetMode(gin.ReleaseMode)
|
gin.SetMode(gin.ReleaseMode)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func run() {
|
func run() {
|
||||||
config.Setup(file.NewSource, file.WithPath(configYml))
|
config.Setup(file.NewSource(file.WithPath(configYml)))
|
||||||
|
|
||||||
application, errs := json.MarshalIndent(config.ApplicationConfig, "", " ") //转换成JSON返回的是byte[]
|
application, errs := json.MarshalIndent(config.ApplicationConfig, "", " ") //转换成JSON返回的是byte[]
|
||||||
if errs != nil {
|
if errs != nil {
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ func run() {
|
|||||||
if !generate {
|
if !generate {
|
||||||
fmt.Println(`start init`)
|
fmt.Println(`start init`)
|
||||||
//1. 读取配置
|
//1. 读取配置
|
||||||
config.Setup(file.NewSource, file.WithPath(configYml))
|
config.Setup(file.NewSource(file.WithPath(configYml)))
|
||||||
//2. 设置日志
|
//2. 设置日志
|
||||||
sdk.Runtime.SetLogger(
|
sdk.Runtime.SetLogger(
|
||||||
logger.SetupLogger(
|
logger.SetupLogger(
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ require (
|
|||||||
github.com/bytedance/go-tagexpr/v2 v2.7.10
|
github.com/bytedance/go-tagexpr/v2 v2.7.10
|
||||||
github.com/casbin/casbin/v2 v2.25.1
|
github.com/casbin/casbin/v2 v2.25.1
|
||||||
github.com/gin-gonic/gin v1.7.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 v1.3.5-rc.3.0.20210609062350-5aeb6bd49b09
|
||||||
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/sdk v1.3.0-rc.3.0.20210609082125-a317acc34456
|
||||||
github.com/google/uuid v1.2.0
|
github.com/google/uuid v1.2.0
|
||||||
github.com/mssola/user_agent v0.5.2
|
github.com/mssola/user_agent v0.5.2
|
||||||
github.com/opentracing/opentracing-go v1.1.0
|
github.com/opentracing/opentracing-go v1.1.0
|
||||||
|
|||||||
Reference in new issue
Block a user