mirror of
https://github.com/skyle1995/NetworkAuth.git
synced 2026-05-25 02:24:05 +08:00
Fix a configuration error
This commit is contained in:
12
cmd/root.go
12
cmd/root.go
@@ -78,19 +78,9 @@ func setupLogrusForNonHTTP() {
|
|||||||
// 设置输出目标(稍后会根据配置文件调整)
|
// 设置输出目标(稍后会根据配置文件调整)
|
||||||
logrus.SetOutput(os.Stdout)
|
logrus.SetOutput(os.Stdout)
|
||||||
if cfgFile != "" {
|
if cfgFile != "" {
|
||||||
// 使用命令行指定的配置文件
|
|
||||||
config.Init(cfgFile)
|
config.Init(cfgFile)
|
||||||
} else {
|
} else {
|
||||||
// 使用默认配置文件路径,基于可执行文件所在目录
|
config.Init("./config.json")
|
||||||
execPath, err := os.Executable()
|
|
||||||
if err != nil {
|
|
||||||
// 如果获取可执行文件路径失败,使用当前工作目录
|
|
||||||
config.Init("./config.json")
|
|
||||||
} else {
|
|
||||||
execDir := filepath.Dir(execPath)
|
|
||||||
configPath := filepath.Join(execDir, "config.json")
|
|
||||||
config.Init(configPath)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 根据配置文件进一步配置logrus
|
// 根据配置文件进一步配置logrus
|
||||||
|
|||||||
Reference in New Issue
Block a user