Skip to content

Commit

Permalink
Merge pull request ehang-io#318 from cnlh/master
Browse files Browse the repository at this point in the history
change default log setting
  • Loading branch information
cnlh authored Dec 18, 2019
2 parents 0559d29 + 0c08d9e commit 2faff58
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 2 additions & 0 deletions cmd/npc/npc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
7 changes: 3 additions & 4 deletions cmd/nps/nps.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (

var (
level string
logType = flag.String("log", "stdout", "Log output mode(stdout|file)")
)

func main() {
Expand All @@ -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"
Expand All @@ -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()
Expand All @@ -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())
Expand Down

0 comments on commit 2faff58

Please sign in to comment.