From 582ae83da398b2026858685712653600d142f100 Mon Sep 17 00:00:00 2001 From: Christian Schwarz Date: Fri, 1 Sep 2017 14:41:19 +0200 Subject: [PATCH] cmd: remove RunCmd --- cmd/replication.go | 70 ---------------------------------------------- 1 file changed, 70 deletions(-) diff --git a/cmd/replication.go b/cmd/replication.go index aa2184f..608bfe7 100644 --- a/cmd/replication.go +++ b/cmd/replication.go @@ -4,7 +4,6 @@ import ( "fmt" "io" "os" - "sync" "time" "github.com/spf13/cobra" @@ -19,12 +18,6 @@ var runArgs struct { once bool } -var RunCmd = &cobra.Command{ - Use: "run", - Short: "run push & pull replication", - Run: cmdRun, -} - var PushCmd = &cobra.Command{ Use: "push", Short: "run push job (first positional argument)", @@ -38,10 +31,6 @@ var PullCmd = &cobra.Command{ } func init() { - RootCmd.AddCommand(RunCmd) - RunCmd.Flags().BoolVar(&runArgs.once, "once", false, "run jobs only once, regardless of configured repeat behavior") - RunCmd.Flags().StringVar(&runArgs.job, "job", "", "run only the given job") - RootCmd.AddCommand(PushCmd) RootCmd.AddCommand(PullCmd) } @@ -83,65 +72,6 @@ func cmdPull(cmd *cobra.Command, args []string) { } -func cmdRun(cmd *cobra.Command, args []string) { - - var wg sync.WaitGroup - wg.Add(1) - go func() { - defer wg.Done() - runner.Start() - }() - - jobs := make([]jobrun.JobMetadata, len(conf.Pulls)+len(conf.Pushs)) - i := 0 - for _, pull := range conf.Pulls { - jobs[i] = jobrun.JobMetadata{ - Name: fmt.Sprintf("pull.%d", i), - RepeatStrategy: pull.RepeatStrategy, - RunFunc: func(log jobrun.Logger) error { - log.Printf("doing pull: %v", pull) - return jobPull(pull, log) - }, - } - i++ - } - for _, push := range conf.Pushs { - jobs[i] = jobrun.JobMetadata{ - Name: fmt.Sprintf("push.%d", i), - RepeatStrategy: push.RepeatStrategy, - RunFunc: func(log jobrun.Logger) error { - log.Printf("doing push: %v", push) - return jobPush(push, log) - }, - } - i++ - } - - for _, j := range jobs { - if runArgs.once { - j.RepeatStrategy = jobrun.NoRepeatStrategy{} - } - if runArgs.job != "" { - if runArgs.job == j.Name { - runner.AddJob(j) - break - } - continue - } - runner.AddJob(j) - } - - for { - select { - case job := <-runner.NotificationChan(): - log.Printf("job %s reported error: %v\n", job.Name, job.LastError) - } - } - - wg.Wait() - -} - type localPullACL struct{} func (a localPullACL) Filter(p *zfs.DatasetPath) (pass bool, err error) {