From 61fdcd2a9e652a6cf4bcf5f6ee163d0b46563992 Mon Sep 17 00:00:00 2001 From: Moraxyc Date: Thu, 31 Oct 2024 00:15:41 +0800 Subject: [PATCH] fix(cli): display version before init app (#463) --- cmd/dashboard/main.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/cmd/dashboard/main.go b/cmd/dashboard/main.go index b59b320..6c68653 100644 --- a/cmd/dashboard/main.go +++ b/cmd/dashboard/main.go @@ -1,6 +1,7 @@ package main import ( + "os" "context" "fmt" "log" @@ -32,13 +33,6 @@ func init() { flag.StringVarP(&dashboardCliParam.ConfigFile, "config", "c", "data/config.yaml", "配置文件路径") flag.StringVar(&dashboardCliParam.DatebaseLocation, "db", "data/sqlite.db", "Sqlite3数据库文件路径") flag.Parse() - - // 初始化 dao 包 - singleton.InitConfigFromPath(dashboardCliParam.ConfigFile) - singleton.InitTimezoneAndCache() - singleton.InitDBFromPath(dashboardCliParam.DatebaseLocation) - singleton.InitLocalizer() - initSystem() } func initSystem() { @@ -59,9 +53,16 @@ func initSystem() { func main() { if dashboardCliParam.Version { fmt.Println(singleton.Version) - return + os.Exit(0) } + // 初始化 dao 包 + singleton.InitConfigFromPath(dashboardCliParam.ConfigFile) + singleton.InitTimezoneAndCache() + singleton.InitDBFromPath(dashboardCliParam.DatebaseLocation) + singleton.InitLocalizer() + initSystem() + // TODO 使用 cmux 在同一端口服务 HTTP 和 gRPC singleton.CleanMonitorHistory() go rpc.ServeRPC(singleton.Conf.GRPCPort)