Add RECHECK_INTERVAL env-var

dev
Ruakij 2 years ago
parent a626ee3c6f
commit f06f9f03ff

@ -4,6 +4,7 @@ import (
"fmt" "fmt"
"net" "net"
"os" "os"
"strconv"
"time" "time"
envChecks "git.ruekov.eu/ruakij/routingtabletowg/lib/environmentchecks" envChecks "git.ruekov.eu/ruakij/routingtabletowg/lib/environmentchecks"
@ -20,6 +21,7 @@ var envRequired = []string{
var envDefaults = map[string]string{ var envDefaults = map[string]string{
"IPV6_FORMAT": "fc12::%02x%02x:%02x%02x/%d", "IPV6_FORMAT": "fc12::%02x%02x:%02x%02x/%d",
"FILTER_PREFIX": "100.100", "FILTER_PREFIX": "100.100",
"RECHECK_INTERVAL": "300",
} }
func main() { func main() {
@ -46,6 +48,12 @@ func main() {
filterPrefix := os.Getenv("FILTER_PREFIX") 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 // Get the IPv4 address of the interface
addrs, err := netlink.AddrList(netInterface, netlink.FAMILY_V4) addrs, err := netlink.AddrList(netInterface, netlink.FAMILY_V4)
@ -138,8 +146,8 @@ func main() {
} }
} }
// Sleep for 300 seconds before running the loop again // Sleep for x seconds before running the loop again
time.Sleep(time.Second * 300) time.Sleep(checkInterval)
} }
} }

Loading…
Cancel
Save