mirror of
https://github.com/nezhahq/nezha.git
synced 2025-01-22 12:48:14 -05:00
fix(cli): display version before init app (#463)
This commit is contained in:
parent
a474b8484b
commit
61fdcd2a9e
@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
@ -32,13 +33,6 @@ func init() {
|
|||||||
flag.StringVarP(&dashboardCliParam.ConfigFile, "config", "c", "data/config.yaml", "配置文件路径")
|
flag.StringVarP(&dashboardCliParam.ConfigFile, "config", "c", "data/config.yaml", "配置文件路径")
|
||||||
flag.StringVar(&dashboardCliParam.DatebaseLocation, "db", "data/sqlite.db", "Sqlite3数据库文件路径")
|
flag.StringVar(&dashboardCliParam.DatebaseLocation, "db", "data/sqlite.db", "Sqlite3数据库文件路径")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
// 初始化 dao 包
|
|
||||||
singleton.InitConfigFromPath(dashboardCliParam.ConfigFile)
|
|
||||||
singleton.InitTimezoneAndCache()
|
|
||||||
singleton.InitDBFromPath(dashboardCliParam.DatebaseLocation)
|
|
||||||
singleton.InitLocalizer()
|
|
||||||
initSystem()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func initSystem() {
|
func initSystem() {
|
||||||
@ -59,9 +53,16 @@ func initSystem() {
|
|||||||
func main() {
|
func main() {
|
||||||
if dashboardCliParam.Version {
|
if dashboardCliParam.Version {
|
||||||
fmt.Println(singleton.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
|
// TODO 使用 cmux 在同一端口服务 HTTP 和 gRPC
|
||||||
singleton.CleanMonitorHistory()
|
singleton.CleanMonitorHistory()
|
||||||
go rpc.ServeRPC(singleton.Conf.GRPCPort)
|
go rpc.ServeRPC(singleton.Conf.GRPCPort)
|
||||||
|
Loading…
Reference in New Issue
Block a user