From 0c08d9e202f04bee653782284e209b01ab56a8f1 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 18 Dec 2019 16:37:04 +0800 Subject: [PATCH] change default log setting --- cmd/npc/npc.go | 2 ++ cmd/nps/nps.go | 7 +++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/cmd/npc/npc.go b/cmd/npc/npc.go index ddce289..da29a05 100644 --- a/cmd/npc/npc.go +++ b/cmd/npc/npc.go @@ -108,6 +108,8 @@ func main() { os.Exit(0) case "install", "start", "stop", "uninstall", "restart": if os.Args[1] == "install" { + service.Control(s, "stop") + service.Control(s, "uninstall") install.InstallNpc() } err := service.Control(s, os.Args[1]) diff --git a/cmd/nps/nps.go b/cmd/nps/nps.go index 95ddf9c..f4c771c 100644 --- a/cmd/nps/nps.go +++ b/cmd/nps/nps.go @@ -26,7 +26,6 @@ import ( var ( level string - logType = flag.String("log", "stdout", "Log output mode(stdout|file)") ) func main() { @@ -48,7 +47,6 @@ func main() { if common.IsWindows() { logPath = strings.Replace(logPath, "\\", "\\\\", -1) } - logs.SetLogger(logs.AdapterFile, `{"level":`+level+`,"filename":"`+logPath+`","daily":false,"maxlines":100000,"color":true}`) // init service options := make(service.KeyValue) options["Restart"] = "on-success" @@ -71,15 +69,15 @@ func main() { logs.Error(err) return } + logs.SetLogger(logs.AdapterConsole, `{"level":`+level+`,"color":true}`) if len(os.Args) > 1 { switch os.Args[1] { - case "debug": - logs.SetLogger(logs.AdapterConsole, `{"level":`+level+`,"color":true}`) case "reload": daemon.InitDaemon("nps", common.GetRunPath(), common.GetTmpPath()) return case "install": // uninstall before + service.Control(s, "stop") service.Control(s, "uninstall") binPath := install.InstallNps() @@ -95,6 +93,7 @@ func main() { } return case "start", "restart", "stop", "uninstall": + logs.SetLogger(logs.AdapterFile, `{"level":`+level+`,"filename":"`+logPath+`","daily":false,"maxlines":100000,"color":true}`) err := service.Control(s, os.Args[1]) if err != nil { logs.Error("Valid actions: %q\n", service.ControlAction, err.Error())