enhance hourly snapshots
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2026-01-14 16:09:13 +11:00
parent 417c7c8127
commit 44ae2094f3
2 changed files with 7 additions and 7 deletions

View File

@@ -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 {

View File

@@ -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 {