mirror of
https://github.com/juanfont/headscale.git
synced 2024-12-02 03:33:05 +00:00
Run handlePrimarySubnetFailover() with a ticker when Serve
This commit is contained in:
parent
03accae98c
commit
d4491bf340
1 changed files with 12 additions and 0 deletions
12
app.go
12
app.go
|
@ -213,6 +213,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() {
|
func (h *Headscale) expireEphemeralNodesWorker() {
|
||||||
namespaces, err := h.ListNamespaces()
|
namespaces, err := h.ListNamespaces()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -491,6 +501,8 @@ func (h *Headscale) Serve() error {
|
||||||
|
|
||||||
go h.expireEphemeralNodes(updateInterval)
|
go h.expireEphemeralNodes(updateInterval)
|
||||||
|
|
||||||
|
go h.failoverSubnetRoutes(updateInterval)
|
||||||
|
|
||||||
if zl.GlobalLevel() == zl.TraceLevel {
|
if zl.GlobalLevel() == zl.TraceLevel {
|
||||||
zerolog.RespLog = true
|
zerolog.RespLog = true
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue