diff --git a/main.go b/main.go index 28f6e47..d0f33ad 100644 --- a/main.go +++ b/main.go @@ -60,6 +60,9 @@ func runHandler(cli *broccli.CLI) int { // and set prometheus' Gauge value go func() { for { + // flag is already validated by cli lib + sleepInt, _ := strconv.Atoi(cli.Flag("sleep")) + // We are never going to have more than 100 runners so getting page 1 only req, err := http.NewRequest("GET", fmt.Sprintf("https://api.github.com/orgs/%s/actions/runners?per_page=100&page=1", cli.Flag("organization")), strings.NewReader("")) if err != nil { @@ -74,6 +77,7 @@ func runHandler(cli *broccli.CLI) int { resp, err := c.Do(req) if err != nil { fmt.Fprint(os.Stderr, "!!! Error making request to GitHub API\n") + time.Sleep(time.Duration(sleepInt*10) * time.Second) continue } @@ -88,8 +92,6 @@ func runHandler(cli *broccli.CLI) int { totalCount.Set(float64(response.TotalCount)) totalCountOnline.Set(float64(response.TotalCountOnline())) - // flag is already validated by cli lib - sleepInt, _ := strconv.Atoi(cli.Flag("sleep")) time.Sleep(time.Duration(sleepInt) * time.Second) } }() diff --git a/version.go b/version.go index d6ae413..833e922 100644 --- a/version.go +++ b/version.go @@ -1,3 +1,3 @@ package main -const VERSION = "0.1.2" +const VERSION = "0.1.3"