From 4482063fb974b59a3f4cd7ce5855f78653a94050 Mon Sep 17 00:00:00 2001 From: kannappanr <30541348+kannappanr@users.noreply.github.com> Date: Sun, 8 Dec 2019 19:44:46 -0800 Subject: [PATCH] Retry mirror forever on watch (#2992) --- cmd/mirror-main.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/cmd/mirror-main.go b/cmd/mirror-main.go index 5e378d53..3c74b226 100644 --- a/cmd/mirror-main.go +++ b/cmd/mirror-main.go @@ -26,6 +26,7 @@ import ( "strings" "sync" "syscall" + "time" "github.com/fatih/color" "github.com/minio/cli" @@ -760,6 +761,11 @@ func runMirror(srcURL, dstURL string, ctx *cli.Context, encKeyDB map[string][]pr userMetaMap, encKeyDB) + go func() { + <-mj.trapCh + os.Exit(globalErrorExitStatus) + }() + if mirrorAllBuckets { // Synchronize buckets using dirDifference function for d := range dirDifference(srcClt, dstClt, srcURL, dstURL) { @@ -860,6 +866,13 @@ func mainMirror(ctx *cli.Context) error { srcURL := args[0] tgtURL := args[1] + if ctx.Bool("watch") { + for { + runMirror(srcURL, tgtURL, ctx, encKeyDB) + time.Sleep(time.Second * 2) + } + } + if errorDetected := runMirror(srcURL, tgtURL, ctx, encKeyDB); errorDetected { return exitStatus(globalErrorExitStatus) }