bootstrap: attemps fetching for 1 minute before giving up

This commit is contained in:
Mikaël Cluseau 2024-11-06 00:42:51 +01:00
parent 5924705b24
commit 91eb83d6e1

View File

@ -8,6 +8,7 @@ import (
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"
"time"
"github.com/rs/zerolog/log" "github.com/rs/zerolog/log"
@ -45,9 +46,18 @@ func bootstrap(cfg *config.Config) {
bootstrapFile := filepath.Join(baseDir, "bootstrap.tar") bootstrapFile := filepath.Join(baseDir, "bootstrap.tar")
err = func() (err error) { 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 { if err != nil {
return return fmt.Errorf("failed to fetch bootstrap")
} }
if resp.StatusCode != http.StatusOK { if resp.StatusCode != http.StatusOK {