bootstrap: attemps fetching for 1 minute before giving up
This commit is contained in:
parent
5924705b24
commit
91eb83d6e1
14
bootstrap.go
14
bootstrap.go
@ -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 {
|
||||||
|
Loading…
Reference in New Issue
Block a user