mirror of
https://github.com/browseros-ai/BrowserOS.git
synced 2026-05-20 20:39:10 +00:00
* refactor(server): remove obsolete controller extension backend * fix: address review feedback for PR #610
33 lines
554 B
Go
33 lines
554 B
Go
package server
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"net/http"
|
|
"time"
|
|
)
|
|
|
|
func WaitForHealth(ctx context.Context, port int, maxAttempts int) bool {
|
|
client := &http.Client{Timeout: time.Second}
|
|
url := fmt.Sprintf("http://127.0.0.1:%d/health", port)
|
|
|
|
for range maxAttempts {
|
|
if ctx.Err() != nil {
|
|
return false
|
|
}
|
|
resp, err := client.Get(url)
|
|
if err == nil {
|
|
resp.Body.Close()
|
|
if resp.StatusCode == 200 {
|
|
return true
|
|
}
|
|
}
|
|
select {
|
|
case <-ctx.Done():
|
|
return false
|
|
case <-time.After(500 * time.Millisecond):
|
|
}
|
|
}
|
|
return false
|
|
}
|