diff --git a/cmd/photographer/exec.go b/cmd/photographer/exec.go index 686e313..532a355 100644 --- a/cmd/photographer/exec.go +++ b/cmd/photographer/exec.go @@ -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) { diff --git a/cmd/photographer/main.go b/cmd/photographer/main.go index be65532..a8ccb10 100644 --- a/cmd/photographer/main.go +++ b/cmd/photographer/main.go @@ -4,7 +4,6 @@ import ( "context" "log" "os" - "runtime/debug" "strings" "time" @@ -61,18 +60,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) { @@ -93,4 +86,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) }