Skip to content

Commit

Permalink
Run handlePrimarySubnetFailover() with a ticker when Serve
Browse files Browse the repository at this point in the history
  • Loading branch information
juanfont authored and kradalby committed Dec 6, 2022
1 parent 6718ff7 commit a506d0f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,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 {
Expand Down Expand Up @@ -497,6 +507,8 @@ func (h *Headscale) Serve() error {

go h.expireEphemeralNodes(updateInterval)

go h.failoverSubnetRoutes(updateInterval)

if zl.GlobalLevel() == zl.TraceLevel {
zerolog.RespLog = true
} else {
Expand Down

0 comments on commit a506d0f

Please sign in to comment.