Skip to content

Commit

Permalink
add log on 24h delay
Browse files Browse the repository at this point in the history
  • Loading branch information
sduchesneau committed Dec 6, 2024
1 parent dd00b7e commit bc18181
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions cmd/purger/purger.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,13 @@ func pruneOldE(cmd *cobra.Command, args []string) error {
if !daemon {
break
}
time.Sleep(time.Until(started.Add(24 * time.Hour)))
if time.Since(started) < time.Hour*24 {
remaining := time.Until(started.Add(24 * time.Hour))
zlog.Info("Waiting before next run...", zap.Duration("remaining", remaining))
time.Sleep(remaining)
} else {
zlog.Info("Next run will start immediately because it took more than 24 hours")
}
}
return nil
}
Expand Down Expand Up @@ -275,7 +281,6 @@ func runPruneOld(ctx context.Context, db *sqlx.DB, network string, maxAgeDays ui
return fmt.Errorf("listing files: %w", err)
}
filesToPurge = append(filesToPurge, fmt.Sprintf("%s/substreams.partial.spkg.zst", path.Dir(relpath))) // go up one directory above and delete the substreams.partial.spkg.zst file
fmt.Println(filesToPurge[len(filesToPurge)-1])

if !force {
fmt.Printf("%s:", cli.PurpleStyle.Render("List of files to purge"))
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.23

require (
cloud.google.com/go/storage v1.27.0
github.com/charmbracelet/huh v0.6.0
github.com/drone/envsubst v1.0.3
github.com/googleapis/gax-go/v2 v2.7.0
github.com/jmoiron/sqlx v1.4.0
Expand All @@ -28,7 +29,6 @@ require (
github.com/catppuccin/go v0.2.0 // indirect
github.com/charmbracelet/bubbles v0.20.0 // indirect
github.com/charmbracelet/bubbletea v1.1.0 // indirect
github.com/charmbracelet/huh v0.6.0 // indirect
github.com/charmbracelet/lipgloss v1.0.0 // indirect
github.com/charmbracelet/x/ansi v0.4.2 // indirect
github.com/charmbracelet/x/exp/strings v0.0.0-20240722160745-212f7b056ed0 // indirect
Expand Down

0 comments on commit bc18181

Please sign in to comment.