API节点自动生成实例代号,用来外界查询多个API节点实例是否为同一个

This commit is contained in:
GoEdgeLab
2022-07-21 19:21:11 +08:00
parent c08aaa2169
commit 384de90f00
4 changed files with 36 additions and 6 deletions

View File

@@ -161,6 +161,20 @@ func main() {
}
}
})
app.On("instance", func() {
var sock = gosock.NewTmpSock(teaconst.ProcessName)
reply, err := sock.Send(&gosock.Command{Code: "instance"})
if err != nil {
fmt.Println("[ERROR]" + err.Error())
} else {
replyJSON, err := json.MarshalIndent(reply.Params, "", " ")
if err != nil {
fmt.Println("[ERROR]marshal result failed: " + err.Error())
} else {
fmt.Println(string(replyJSON))
}
}
})
app.Run(func() {
nodes.NewAPINode().Start()