mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-05 00:34:01 +08:00
增加 edge-node reload 命令/优化命令行帮助
This commit is contained in:
@@ -22,7 +22,9 @@ func main() {
|
||||
app := apps.NewAppCmd().
|
||||
Version(teaconst.Version).
|
||||
Product(teaconst.ProductName).
|
||||
Usage(teaconst.ProcessName + " [-v|start|stop|restart|status|quit|test|service|daemon|pprof]")
|
||||
Usage(teaconst.ProcessName + " [-v|start|stop|restart|status|quit|test|reload|service|daemon|pprof]").
|
||||
Usage(teaconst.ProcessName + " [trackers|goman|conns|gc]").
|
||||
Usage(teaconst.ProcessName + " [ip.drop|ip.reject|ip.remove] IP")
|
||||
|
||||
app.On("test", func() {
|
||||
err := nodes.NewNode().Test()
|
||||
@@ -30,6 +32,20 @@ func main() {
|
||||
_, _ = os.Stderr.WriteString(err.Error())
|
||||
}
|
||||
})
|
||||
app.On("reload", func() {
|
||||
var sock = gosock.NewTmpSock(teaconst.ProcessName)
|
||||
reply, err := sock.Send(&gosock.Command{Code: "reload"})
|
||||
if err != nil {
|
||||
fmt.Println("[ERROR]" + err.Error())
|
||||
} else {
|
||||
var params = maps.NewMap(reply.Params)
|
||||
if params.Has("error") {
|
||||
fmt.Println("[ERROR]" + params.GetString("error"))
|
||||
} else {
|
||||
fmt.Println("ok")
|
||||
}
|
||||
}
|
||||
})
|
||||
app.On("daemon", func() {
|
||||
nodes.NewNode().Daemon()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user