Skip to content

Commit

Permalink
try exiting
Browse files Browse the repository at this point in the history
  • Loading branch information
fraidev committed Aug 18, 2023
1 parent d656582 commit 59a21c5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
6 changes: 2 additions & 4 deletions cmd/photographer/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ func createSnapshot(historyMode snapshot.HistoryModeType) {
log.Fatalf("%v \n", err)
}

log.Println("snapshot export stdout:")
log.Println(stdout.String())
log.Println("snapshot export stderr:")
log.Println(stderr.String())
log.Printf("snapshot export stdout: \n%s\n", stdout.String())
log.Printf("snapshot export stderr: \n%s\n", stderr.String())
}

func getSnapshotNames(historyMode snapshot.HistoryModeType) (string, error) {
Expand Down
11 changes: 5 additions & 6 deletions cmd/photographer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,12 @@ func task() {
// Check if today the rolling snapshot already exists
execute(ctx, snapshotStorage, snapshot.ROLLING, network)

// Reset GC
debug.FreeOSMemory()

// Check if today the full snapshot already exists
execute(ctx, snapshotStorage, snapshot.FULL, network)

snapshotStorage.DeleteExpiredSnapshots(ctx, maxDays, maxMonths)

log.Printf("Snapshot job took %s", time.Since(start))

// Reset GC
debug.FreeOSMemory()
}

func execute(ctx context.Context, snapshotStorage *util.SnapshotStorage, historyMode snapshot.HistoryModeType, chain string) {
Expand All @@ -93,4 +87,9 @@ func execute(ctx context.Context, snapshotStorage *util.SnapshotStorage, history
log.Fatalf("%v \n", err)
}
snapshotStorage.EphemeralUpload(ctx, snapshotfilename)

// If we are here, it means that the snapshot was uploaded successfully
// So we already deleted the snapshot
// Then we can exit to have sure that we're not using more memory than we need
os.Exit(0)
}

0 comments on commit 59a21c5

Please sign in to comment.