support use of random free port for healthcheck

This commit is contained in:
paspo
2026-07-03 18:18:48 +02:00
parent e7d2f5239d
commit b9adb28e90
+9 -1
View File
@@ -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