mirror of
https://github.com/ehang-io/nps.git
synced 2025-07-03 04:53:50 +00:00
Merge pull request #207 from evangwt/master
fix: close health check tcp connection
This commit is contained in:
commit
445ed1dd60
@ -71,7 +71,11 @@ func check(t *file.Health) {
|
|||||||
var rs *http.Response
|
var rs *http.Response
|
||||||
for _, v := range arr {
|
for _, v := range arr {
|
||||||
if t.HealthCheckType == "tcp" {
|
if t.HealthCheckType == "tcp" {
|
||||||
_, err = net.DialTimeout("tcp", v, time.Duration(t.HealthCheckTimeout)*time.Second)
|
var c net.Conn
|
||||||
|
c, err = net.DialTimeout("tcp", v, time.Duration(t.HealthCheckTimeout)*time.Second)
|
||||||
|
if err == nil {
|
||||||
|
c.Close()
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
client := &http.Client{}
|
client := &http.Client{}
|
||||||
client.Timeout = time.Duration(t.HealthCheckTimeout) * time.Second
|
client.Timeout = time.Duration(t.HealthCheckTimeout) * time.Second
|
||||||
|
Loading…
x
Reference in New Issue
Block a user