From 91eb83d6e1f307a658c8aad158512b0b41c62ad1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Cluseau?= Date: Wed, 6 Nov 2024 00:42:51 +0100 Subject: [PATCH] bootstrap: attemps fetching for 1 minute before giving up --- bootstrap.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/bootstrap.go b/bootstrap.go index fa41b6f..c792324 100644 --- a/bootstrap.go +++ b/bootstrap.go @@ -8,6 +8,7 @@ import ( "os" "path/filepath" "strings" + "time" "github.com/rs/zerolog/log" @@ -45,9 +46,18 @@ func bootstrap(cfg *config.Config) { bootstrapFile := filepath.Join(baseDir, "bootstrap.tar") err = func() (err error) { - resp, err := http.Get(seed) + var resp *http.Response + + start := time.Now() + for time.Since(start) <= time.Minute { + resp, err = http.Get(seed) + if err == nil { + break + } + time.Sleep(time.Second) + } if err != nil { - return + return fmt.Errorf("failed to fetch bootstrap") } if resp.StatusCode != http.StatusOK {