mirror of
https://github.com/community-unscripted/telemetry-service.git
synced 2026-07-01 20:54:03 -04:00
Initialize empty stats store on bootstrap failure
If statsAllTime.Bootstrap fails, log the error but continue by initializing an empty stats map with a "_marker" entry set to today's date. This prevents repeated bootstrap attempts and allows the service to build stats incrementally going forward. The change acquires the stats mutex while updating the map and adds an informational log message.
This commit is contained in:
@@ -1861,6 +1861,14 @@ func main() {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 900*time.Second)
|
||||
if err := statsAllTime.Bootstrap(ctx, "ProxmoxVE"); err != nil {
|
||||
log.Printf("[STATS:alltime] Bootstrap failed: %v", err)
|
||||
log.Println("[STATS:alltime] Continuing with empty store - will build up incrementally")
|
||||
// Initialize with today's date to start incremental updates from now on
|
||||
today := time.Now().Format("2006-01-02")
|
||||
statsAllTime.mu.Lock()
|
||||
statsAllTime.stats = map[string]*CachedScriptStat{
|
||||
"_marker": {LastDate: today}, // Marker to prevent re-bootstrap
|
||||
}
|
||||
statsAllTime.mu.Unlock()
|
||||
}
|
||||
cancel()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user