From f06f9f03ffac32d64a4a8df32fded5af6deb302f Mon Sep 17 00:00:00 2001 From: Ruakij Date: Sat, 1 Apr 2023 12:16:56 +0200 Subject: [PATCH] Add RECHECK_INTERVAL env-var --- cmd/app/main.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/cmd/app/main.go b/cmd/app/main.go index 23ae867..0e94083 100644 --- a/cmd/app/main.go +++ b/cmd/app/main.go @@ -4,6 +4,7 @@ import ( "fmt" "net" "os" + "strconv" "time" envChecks "git.ruekov.eu/ruakij/routingtabletowg/lib/environmentchecks" @@ -20,6 +21,7 @@ var envRequired = []string{ var envDefaults = map[string]string{ "IPV6_FORMAT": "fc12::%02x%02x:%02x%02x/%d", "FILTER_PREFIX": "100.100", + "RECHECK_INTERVAL": "300", } func main() { @@ -46,6 +48,12 @@ func main() { filterPrefix := os.Getenv("FILTER_PREFIX") + checkIntervalStr := os.Getenv("RECHECK_INTERVAL") + checkIntervalSec, err := strconv.Atoi(checkIntervalStr) + if err != nil { + logger.Error.Fatalf("Couldn't read RECHECK_INTERVAL '%s': %s", checkIntervalStr, err) + } + checkInterval := time.Second * time.Duration(checkIntervalSec) // Get the IPv4 address of the interface addrs, err := netlink.AddrList(netInterface, netlink.FAMILY_V4) @@ -138,8 +146,8 @@ func main() { } } - // Sleep for 300 seconds before running the loop again - time.Sleep(time.Second * 300) + // Sleep for x seconds before running the loop again + time.Sleep(checkInterval) } }