mirror of
				https://github.com/juanfont/headscale.git
				synced 2025-11-04 01:51:04 +01:00 
			
		
		
		
	Run handlePrimarySubnetFailover() with a ticker when Serve
This commit is contained in:
		
							parent
							
								
									6718ff71d3
								
							
						
					
					
						commit
						a506d0fcc8
					
				
							
								
								
									
										12
									
								
								app.go
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								app.go
									
									
									
									
									
								
							@ -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 {
 | 
			
		||||
@ -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 {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user