优化系统goroutine使用,减少goroutine数量,增加goman查看goroutine数量指令

This commit is contained in:
GoEdgeLab
2021-12-08 15:17:45 +08:00
parent 7a2bfda436
commit 54bf0ab39d
48 changed files with 469 additions and 146 deletions

View File

@@ -1,6 +1,7 @@
package main
import (
"encoding/json"
"fmt"
"github.com/TeaOSLab/EdgeNode/internal/apps"
teaconst "github.com/TeaOSLab/EdgeNode/internal/const"
@@ -88,6 +89,25 @@ func main() {
}
}
})
app.On("goman", func() {
var sock = gosock.NewTmpSock(teaconst.ProcessName)
reply, err := sock.Send(&gosock.Command{Code: "goman"})
if err != nil {
fmt.Println("[ERROR]" + err.Error())
} else {
instances, ok := reply.Params["result"]
if ok {
instancesJSON, err := json.MarshalIndent(instances, "", " ")
if err != nil {
fmt.Println("[ERROR]" + err.Error())
} else {
fmt.Println(string(instancesJSON))
}
} else {
fmt.Println("no instances yet.")
}
}
})
app.Run(func() {
node := nodes.NewNode()
node.Start()