INNER CODE UNIT · Go
waitForHealthy
openocta/openocta · src/cmd/openocta-launcher/main.go:70
func waitForHealthy(url string, timeout time.Duration) error {
deadline := time.Now().Add(timeout)
client := &http.Client{Timeout: 800 * time.Millisecond}
for time.Now().Before(deadline) {
req, _ := http.NewRequest("GET", url, nil)
res, err := client.Do(req)
if err == nil {
_ = res.Body.Close()
if res.StatusCode >= 200 && res.StatusCode < 500 {
return nil
}
}
time.Sleep(250 * time.Millisecond)
}
return errors.New("gateway health check timeout")
}
func openBrowser(url string) error {