diff --git a/cmd/nps/nps.go b/cmd/nps/nps.go index db6df9e..5b1c5b4 100644 --- a/cmd/nps/nps.go +++ b/cmd/nps/nps.go @@ -40,15 +40,8 @@ func main() { common.PrintVersion() return } - - if len(os.Args) <= 1 { - if err := beego.LoadAppConfig("ini", filepath.Join("./", "conf", "nps.conf")); err != nil { - log.Fatalln("load config file error", err.Error()) - } - } else { - if err := beego.LoadAppConfig("ini", filepath.Join(common.GetRunPath(), "conf", "nps.conf")); err != nil { - log.Fatalln("load config file error", err.Error()) - } + if err := beego.LoadAppConfig("ini", filepath.Join(common.GetRunPath(), "conf", "nps.conf")); err != nil { + log.Fatalln("load config file error", err.Error()) } common.InitPProfFromFile() diff --git a/lib/common/run.go b/lib/common/run.go index 6e4eb11..6370071 100644 --- a/lib/common/run.go +++ b/lib/common/run.go @@ -11,8 +11,12 @@ import ( //windows system, select the C:\Program Files\nps as config directory if exist, or select ./ func GetRunPath() string { var path string - if path = GetInstallPath(); !FileExists(path) { - return GetAppPath() + if len(os.Args) <= 1 { + return "./" + } else { + if path = GetInstallPath(); !FileExists(path) { + return GetAppPath() + } } return path }