去除监听配置文件功能,并优化打包体积
This commit is contained in:
parent
a8e9c9368f
commit
b2b393054f
@ -6,7 +6,6 @@ import (
|
||||
"github.com/1340691923/xwl_bi/model"
|
||||
"github.com/1340691923/xwl_bi/platform-basic-libs/util"
|
||||
"github.com/1340691923/xwl_bi/router"
|
||||
"github.com/fsnotify/fsnotify"
|
||||
"go.uber.org/zap"
|
||||
"log"
|
||||
"os"
|
||||
@ -29,7 +28,6 @@ type App struct {
|
||||
configFileExt,
|
||||
appName string
|
||||
cmdName string
|
||||
monitorConfigChange bool
|
||||
InitFnObservers []InitFnObserver
|
||||
err error
|
||||
deferFuncs []func()
|
||||
@ -84,11 +82,6 @@ func NewApp(cmdName string, opts ...NewAppOptions) *App {
|
||||
return app
|
||||
}
|
||||
|
||||
func (this *App) MonitorConfigChange() *App {
|
||||
this.monitorConfigChange = true
|
||||
return this
|
||||
}
|
||||
|
||||
// 初始化配置
|
||||
func (this *App) InitConfig() *App {
|
||||
config := viper.New()
|
||||
@ -108,29 +101,6 @@ func (this *App) InitConfig() *App {
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -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"
|
@ -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"
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -41,7 +41,6 @@ func main() {
|
||||
|
||||
err := app.InitConfig().
|
||||
NotifyInitFnObservers().
|
||||
MonitorConfigChange().
|
||||
Error()
|
||||
|
||||
if err != nil {
|
||||
|
@ -45,7 +45,6 @@ func main() {
|
||||
err := app.
|
||||
InitConfig().
|
||||
NotifyInitFnObservers().
|
||||
MonitorConfigChange().
|
||||
Error()
|
||||
|
||||
if err != nil {
|
||||
|
@ -53,7 +53,7 @@ func main() {
|
||||
application.RegisterInitFnObserver(application.RefreshTableId),
|
||||
)
|
||||
|
||||
err := app.InitConfig().NotifyInitFnObservers().MonitorConfigChange().Error()
|
||||
err := app.InitConfig().NotifyInitFnObservers().Error()
|
||||
|
||||
if err != nil {
|
||||
logs.Logger.Error("数据系统 初始化失败", zap.Error(err))
|
||||
|
Loading…
x
Reference in New Issue
Block a user