mirror of
https://github.com/ehang-io/nps.git
synced 2025-07-02 20:30:43 +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
|
||||
for _, v := range arr {
|
||||
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 {
|
||||
client := &http.Client{}
|
||||
client.Timeout = time.Duration(t.HealthCheckTimeout) * time.Second
|
||||
|
Loading…
x
Reference in New Issue
Block a user