enhance hourly snapshots
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user