mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-11 22:00:25 +08:00
优化代码
This commit is contained in:
@@ -95,16 +95,11 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("[ERROR]" + err.Error())
|
fmt.Println("[ERROR]" + err.Error())
|
||||||
} else {
|
} else {
|
||||||
instances, ok := reply.Params["result"]
|
instancesJSON, err := json.MarshalIndent(reply.Params, "", " ")
|
||||||
if ok {
|
if err != nil {
|
||||||
instancesJSON, err := json.MarshalIndent(instances, "", " ")
|
fmt.Println("[ERROR]" + err.Error())
|
||||||
if err != nil {
|
|
||||||
fmt.Println("[ERROR]" + err.Error())
|
|
||||||
} else {
|
|
||||||
fmt.Println(string(instancesJSON))
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
fmt.Println("no instances yet.")
|
fmt.Println(string(instancesJSON))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -88,3 +88,15 @@ func (this *HTTPRateWriter) Hijack() (conn net.Conn, buf *bufio.ReadWriter, err
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Flush Flush
|
||||||
|
func (this *HTTPRateWriter) Flush() {
|
||||||
|
if this.parentWriter == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
flusher, ok := this.parentWriter.(http.Flusher)
|
||||||
|
if ok {
|
||||||
|
flusher.Flush()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -170,8 +170,10 @@ func (this *Node) Start() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
// 统计
|
// 统计
|
||||||
go stats.SharedTrafficStatManager.Start(func() *nodeconfigs.NodeConfig {
|
goman.New(func() {
|
||||||
return sharedNodeConfig
|
stats.SharedTrafficStatManager.Start(func() *nodeconfigs.NodeConfig {
|
||||||
|
return sharedNodeConfig
|
||||||
|
})
|
||||||
})
|
})
|
||||||
goman.New(func() {
|
goman.New(func() {
|
||||||
stats.SharedHTTPRequestStatManager.Start()
|
stats.SharedHTTPRequestStatManager.Start()
|
||||||
@@ -618,6 +620,7 @@ func (this *Node) listenSock() error {
|
|||||||
|
|
||||||
_ = cmd.Reply(&gosock.Command{
|
_ = cmd.Reply(&gosock.Command{
|
||||||
Params: map[string]interface{}{
|
Params: map[string]interface{}{
|
||||||
|
"total": runtime.NumGoroutine(),
|
||||||
"result": result,
|
"result": result,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user