소스 검색

change default log setting

unknown 5 년 전
부모
커밋
0c08d9e202
2개의 변경된 파일5개의 추가작업 그리고 4개의 파일을 삭제
  1. 2 0
      cmd/npc/npc.go
  2. 3 4
      cmd/nps/nps.go

+ 2 - 0
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])

+ 3 - 4
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())