mirror of
https://github.com/ehang-io/nps.git
synced 2025-07-03 04:53:50 +00:00
commit
2faff58341
@ -108,6 +108,8 @@ func main() {
|
|||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
case "install", "start", "stop", "uninstall", "restart":
|
case "install", "start", "stop", "uninstall", "restart":
|
||||||
if os.Args[1] == "install" {
|
if os.Args[1] == "install" {
|
||||||
|
service.Control(s, "stop")
|
||||||
|
service.Control(s, "uninstall")
|
||||||
install.InstallNpc()
|
install.InstallNpc()
|
||||||
}
|
}
|
||||||
err := service.Control(s, os.Args[1])
|
err := service.Control(s, os.Args[1])
|
||||||
|
@ -26,7 +26,6 @@ import (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
level string
|
level string
|
||||||
logType = flag.String("log", "stdout", "Log output mode(stdout|file)")
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@ -48,7 +47,6 @@ func main() {
|
|||||||
if common.IsWindows() {
|
if common.IsWindows() {
|
||||||
logPath = strings.Replace(logPath, "\\", "\\\\", -1)
|
logPath = strings.Replace(logPath, "\\", "\\\\", -1)
|
||||||
}
|
}
|
||||||
logs.SetLogger(logs.AdapterFile, `{"level":`+level+`,"filename":"`+logPath+`","daily":false,"maxlines":100000,"color":true}`)
|
|
||||||
// init service
|
// init service
|
||||||
options := make(service.KeyValue)
|
options := make(service.KeyValue)
|
||||||
options["Restart"] = "on-success"
|
options["Restart"] = "on-success"
|
||||||
@ -71,15 +69,15 @@ func main() {
|
|||||||
logs.Error(err)
|
logs.Error(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
logs.SetLogger(logs.AdapterConsole, `{"level":`+level+`,"color":true}`)
|
||||||
if len(os.Args) > 1 {
|
if len(os.Args) > 1 {
|
||||||
switch os.Args[1] {
|
switch os.Args[1] {
|
||||||
case "debug":
|
|
||||||
logs.SetLogger(logs.AdapterConsole, `{"level":`+level+`,"color":true}`)
|
|
||||||
case "reload":
|
case "reload":
|
||||||
daemon.InitDaemon("nps", common.GetRunPath(), common.GetTmpPath())
|
daemon.InitDaemon("nps", common.GetRunPath(), common.GetTmpPath())
|
||||||
return
|
return
|
||||||
case "install":
|
case "install":
|
||||||
// uninstall before
|
// uninstall before
|
||||||
|
service.Control(s, "stop")
|
||||||
service.Control(s, "uninstall")
|
service.Control(s, "uninstall")
|
||||||
|
|
||||||
binPath := install.InstallNps()
|
binPath := install.InstallNps()
|
||||||
@ -95,6 +93,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
case "start", "restart", "stop", "uninstall":
|
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])
|
err := service.Control(s, os.Args[1])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logs.Error("Valid actions: %q\n", service.ControlAction, err.Error())
|
logs.Error("Valid actions: %q\n", service.ControlAction, err.Error())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user