mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-03 08:37:37 +00:00
use urfave defaulting method for correct help text (#8972)
Co-authored-by: Preston Van Loon <preston@prysmaticlabs.com>
This commit is contained in:
parent
fc898d541f
commit
2b6c7e7b37
@ -3,6 +3,8 @@
|
|||||||
package flags
|
package flags
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -25,6 +27,7 @@ var (
|
|||||||
// ScrapeIntervalFlag defines a flag for the frequency of scraping.
|
// ScrapeIntervalFlag defines a flag for the frequency of scraping.
|
||||||
ScrapeIntervalFlag = &cli.DurationFlag{
|
ScrapeIntervalFlag = &cli.DurationFlag{
|
||||||
Name: "scrape-interval",
|
Name: "scrape-interval",
|
||||||
Usage: "Frequency of scraping expressed as a duration, eg 2m or 1m5s. Default is 60s.",
|
Usage: "Frequency of scraping expressed as a duration, eg 2m or 1m5s.",
|
||||||
|
Value: 60 * time.Second,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -28,7 +28,6 @@ var appFlags = []cli.Flag{
|
|||||||
flags.ClientStatsAPIURLFlag,
|
flags.ClientStatsAPIURLFlag,
|
||||||
flags.ScrapeIntervalFlag,
|
flags.ScrapeIntervalFlag,
|
||||||
}
|
}
|
||||||
var scrapeInterval = 60 * time.Second
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
app := cli.App{}
|
app := cli.App{}
|
||||||
@ -101,10 +100,6 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func run(ctx *cli.Context) error {
|
func run(ctx *cli.Context) error {
|
||||||
if ctx.IsSet(flags.ScrapeIntervalFlag.Name) {
|
|
||||||
scrapeInterval = ctx.Duration(flags.ScrapeIntervalFlag.Name)
|
|
||||||
}
|
|
||||||
|
|
||||||
var upd clientstats.Updater
|
var upd clientstats.Updater
|
||||||
if ctx.IsSet(flags.ClientStatsAPIURLFlag.Name) {
|
if ctx.IsSet(flags.ClientStatsAPIURLFlag.Name) {
|
||||||
u := ctx.String(flags.ClientStatsAPIURLFlag.Name)
|
u := ctx.String(flags.ClientStatsAPIURLFlag.Name)
|
||||||
@ -124,7 +119,7 @@ func run(ctx *cli.Context) error {
|
|||||||
scrapers = append(scrapers, clientstats.NewValidatorScraper(u))
|
scrapers = append(scrapers, clientstats.NewValidatorScraper(u))
|
||||||
}
|
}
|
||||||
|
|
||||||
ticker := time.NewTicker(scrapeInterval)
|
ticker := time.NewTicker(ctx.Duration(flags.ScrapeIntervalFlag.Name))
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
|
Loading…
Reference in New Issue
Block a user