mirror of
https://github.com/shizunge/endlessh-go.git
synced 2026-08-07 07:15:02 +00:00
support use of random free port for healthcheck
This commit is contained in:
@@ -190,7 +190,15 @@ func main() {
|
|||||||
})
|
})
|
||||||
clients := startSending(*maxClients, *bannerMaxLength, records)
|
clients := startSending(*maxClients, *bannerMaxLength, records)
|
||||||
|
|
||||||
// Start the healthcheck listener.
|
if *healthcheckPort == "0" || *healthcheckPort == "" {
|
||||||
|
l, err := net.Listen("tcp", *healthcheckHost+":0")
|
||||||
|
if err != nil {
|
||||||
|
glog.Fatalf("Failed to pick a free healthcheck port: %v", err)
|
||||||
|
}
|
||||||
|
actualPort := l.Addr().(*net.TCPAddr).Port
|
||||||
|
*healthcheckPort = strconv.Itoa(actualPort)
|
||||||
|
l.Close()
|
||||||
|
}
|
||||||
health.StartListener(*healthcheckHost, *healthcheckPort)
|
health.StartListener(*healthcheckHost, *healthcheckPort)
|
||||||
|
|
||||||
interval := time.Duration(*intervalMs) * time.Millisecond
|
interval := time.Duration(*intervalMs) * time.Millisecond
|
||||||
|
|||||||
Reference in New Issue
Block a user