去除监听配置文件功能,并优化打包体积

This commit is contained in:
1340691923@qq.com 2022-02-07 15:52:15 +08:00
parent a8e9c9368f
commit b2b393054f
10 changed files with 7 additions and 39 deletions

View File

@ -6,7 +6,6 @@ import (
"github.com/1340691923/xwl_bi/model" "github.com/1340691923/xwl_bi/model"
"github.com/1340691923/xwl_bi/platform-basic-libs/util" "github.com/1340691923/xwl_bi/platform-basic-libs/util"
"github.com/1340691923/xwl_bi/router" "github.com/1340691923/xwl_bi/router"
"github.com/fsnotify/fsnotify"
"go.uber.org/zap" "go.uber.org/zap"
"log" "log"
"os" "os"
@ -29,7 +28,6 @@ type App struct {
configFileExt, configFileExt,
appName string appName string
cmdName string cmdName string
monitorConfigChange bool
InitFnObservers []InitFnObserver InitFnObservers []InitFnObserver
err error err error
deferFuncs []func() deferFuncs []func()
@ -84,11 +82,6 @@ func NewApp(cmdName string, opts ...NewAppOptions) *App {
return app return app
} }
func (this *App) MonitorConfigChange() *App {
this.monitorConfigChange = true
return this
}
// 初始化配置 // 初始化配置
func (this *App) InitConfig() *App { func (this *App) InitConfig() *App {
config := viper.New() config := viper.New()
@ -108,29 +101,6 @@ func (this *App) InitConfig() *App {
model.CmdName = this.cmdName model.CmdName = this.cmdName
if this.monitorConfigChange {
config.OnConfigChange(func(e fsnotify.Event) {
log.Println("检测配置文件更新,应用配置修改中...")
if err := config.ReadInConfig(); err != nil {
log.Println("应用配置修改失败", err)
return
}
if err := config.Unmarshal(&model.GlobConfig); err != nil {
log.Println("应用配置修改失败", err)
return
}
this.Close()
if err := this.NotifyInitFnObservers().Error(); err != nil {
log.Println("应用配置修改失败", err)
return
}
log.Println("应用配置修改完成!")
})
}
config.WatchConfig()
return this return this
} }

View File

@ -1,2 +1,2 @@
cmd /k "cd vue && npm run build:prod && cd .. && set goos=linux&&go build -o bin/linux/manager cmd/manager/main.go && go build -o bin/linux/report_server cmd/report_server/main.go && go build -o bin/linux/sinker cmd/sinker/main.go && go build -o bin/linux/init_app cmd/init_app/main.go" cd vue && npm run build:prod && cd .. && set goos=linux&&go build -ldflags="-w -s" -o bin/linux/manager cmd/manager/main.go && go build -ldflags="-w -s" -o bin/linux/report_server cmd/report_server/main.go && go build -ldflags="-w -s" -o bin/linux/sinker cmd/sinker/main.go && go build -ldflags="-w -s" -o bin/linux/init_app cmd/init_app/main.go
echo "build success" echo "build success"

View File

@ -1,2 +1,2 @@
cmd /k "cd vue && npm run build:prod && cd .. && go build -o bin/win/manager.exe cmd/manager/main.go && go build -o bin/win/report_server.exe cmd/report_server/main.go && go build -o bin/win/sinker.exe cmd/sinker/main.go && go build -o bin/win/init_app.exe cmd/init_app/main.go" cd vue && npm run build:prod && cd .. && go build -ldflags="-w -s" -o bin/win/manager.exe cmd/manager/main.go && go build -ldflags="-w -s" -o bin/win/report_server.exe cmd/report_server/main.go && go build -ldflags="-w -s" -o bin/win/sinker.exe cmd/sinker/main.go && go build -ldflags="-w -s" -o bin/win/init_app.exe cmd/init_app/main.go
echo "build success" echo "build success"

View File

@ -1,2 +1,2 @@
cmd /k " set goos=linux&& go build -o bin/linux/init_app cmd/init_app/main.go" set goos=linux&& go build -ldflags="-w -s" -o bin/linux/init_app cmd/init_app/main.go
echo "build success" echo "build success"

View File

@ -1,2 +1,2 @@
cmd /k "cd vue && npm run build:stage && cd .. && set goos=linux&&go build -o bin/linux/manager cmd/manager/main.go " cd vue && npm run build:stage && cd .. && set goos=linux&&go build -ldflags="-w -s" -o bin/linux/manager cmd/manager/main.go
echo "build success" echo "build success"

View File

@ -1,2 +1,2 @@
cmd /k " set goos=linux&& go build -o bin/linux/report_server cmd/report_server/main.go" set goos=linux&& go build -ldflags="-w -s" -o bin/linux/report_server cmd/report_server/main.go
echo "build success" echo "build success"

View File

@ -1,2 +1,2 @@
cmd /k " set goos=linux&& go build -o bin/linux/sinker cmd/sinker/main.go " set goos=linux&& go build -ldflags="-w -s" -o bin/linux/sinker cmd/sinker/main.go
echo "build success" echo "build success"

View File

@ -41,7 +41,6 @@ func main() {
err := app.InitConfig(). err := app.InitConfig().
NotifyInitFnObservers(). NotifyInitFnObservers().
MonitorConfigChange().
Error() Error()
if err != nil { if err != nil {

View File

@ -45,7 +45,6 @@ func main() {
err := app. err := app.
InitConfig(). InitConfig().
NotifyInitFnObservers(). NotifyInitFnObservers().
MonitorConfigChange().
Error() Error()
if err != nil { if err != nil {

View File

@ -53,7 +53,7 @@ func main() {
application.RegisterInitFnObserver(application.RefreshTableId), application.RegisterInitFnObserver(application.RefreshTableId),
) )
err := app.InitConfig().NotifyInitFnObservers().MonitorConfigChange().Error() err := app.InitConfig().NotifyInitFnObservers().Error()
if err != nil { if err != nil {
logs.Logger.Error("数据系统 初始化失败", zap.Error(err)) logs.Logger.Error("数据系统 初始化失败", zap.Error(err))