From 358ed64b9863bd477725268569a17c732bca8672 Mon Sep 17 00:00:00 2001 From: Juan Font Date: Fri, 25 Nov 2022 15:11:22 +0000 Subject: [PATCH] Run handlePrimarySubnetFailover() with a ticker when Serve --- app.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app.go b/app.go index 69d40794..d840fd78 100644 --- a/app.go +++ b/app.go @@ -218,6 +218,16 @@ func (h *Headscale) expireEphemeralNodes(milliSeconds int64) { } } +func (h *Headscale) failoverSubnetRoutes(milliSeconds int64) { + ticker := time.NewTicker(time.Duration(milliSeconds) * time.Millisecond) + for range ticker.C { + err := h.handlePrimarySubnetFailover() + if err != nil { + log.Error().Err(err).Msg("failed to handle primary subnet failover") + } + } +} + func (h *Headscale) expireEphemeralNodesWorker() { namespaces, err := h.ListNamespaces() if err != nil { @@ -496,6 +506,8 @@ func (h *Headscale) Serve() error { go h.expireEphemeralNodes(updateInterval) + go h.failoverSubnetRoutes(updateInterval) + if zl.GlobalLevel() == zl.TraceLevel { zerolog.RespLog = true } else {