From 44ae2094f370de9a9dcc15ad677981a423e2e4a6 Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Wed, 14 Jan 2026 16:09:13 +1100 Subject: [PATCH] enhance hourly snapshots --- internal/tasks/inventorySnapshots.go | 11 +++++------ internal/utils/utils.go | 3 ++- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/internal/tasks/inventorySnapshots.go b/internal/tasks/inventorySnapshots.go index 3835e5b..70a00e3 100644 --- a/internal/tasks/inventorySnapshots.go +++ b/internal/tasks/inventorySnapshots.go @@ -94,22 +94,21 @@ func (c *CronTask) RunVcenterSnapshotHourly(ctx context.Context, logger *slog.Lo if concurrencyLimit > 0 { sem = make(chan struct{}, concurrencyLimit) } + c.Logger.Info("Starting hourly snapshots", "vcenter_count", len(c.Settings.Values.Settings.VcenterAddresses), "concurrency_limit", concurrencyLimit) for _, url := range c.Settings.Values.Settings.VcenterAddresses { - url := url - if sem != nil { - sem <- struct{}{} - } wg.Add(1) - go func() { + go func(url string) { defer wg.Done() if sem != nil { + sem <- struct{}{} defer func() { <-sem }() } + c.Logger.Info("Starting hourly snapshot for vcenter", "url", url) if err := c.captureHourlySnapshotForVcenter(ctx, startTime, tableName, url); err != nil { atomic.AddInt64(&errCount, 1) c.Logger.Error("hourly snapshot failed", "error", err, "url", url) } - }() + }(url) } wg.Wait() if errCount > 0 { diff --git a/internal/utils/utils.go b/internal/utils/utils.go index b83421f..c93839d 100644 --- a/internal/utils/utils.go +++ b/internal/utils/utils.go @@ -20,10 +20,11 @@ func GetFilePath(path string) string { // check if filename exists if _, err := os.Stat(path); os.IsNotExist((err)) { - slog.Info("File not found, searching in same directory as binary", "filename", path) if filepath.IsAbs(path) { + slog.Info("File not found, using absolute path", "filename", path) return path } + slog.Info("File not found, searching in same directory as binary", "filename", path) // if not, check that it exists in the same directory as the currently executing binary ex, err2 := os.Executable() if err2 != nil {