diff --git a/app/vmctl/influx.go b/app/vmctl/influx.go index ee2462c5e..8e11d91be 100644 --- a/app/vmctl/influx.go +++ b/app/vmctl/influx.go @@ -52,6 +52,7 @@ func (ip *influxProcessor) run(silent, verbose bool) error { if err := barpool.Start(); err != nil { return err } + defer barpool.Stop() seriesCh := make(chan *influx.Series) errCh := make(chan error) @@ -96,7 +97,7 @@ func (ip *influxProcessor) run(silent, verbose bool) error { for err := range errCh { return fmt.Errorf("import process failed: %s", err) } - barpool.Stop() + log.Println("Import finished!") log.Print(ip.im.Stats()) return nil diff --git a/app/vmctl/opentsdb.go b/app/vmctl/opentsdb.go index fdbb7d9c3..78c3275b6 100644 --- a/app/vmctl/opentsdb.go +++ b/app/vmctl/opentsdb.go @@ -82,6 +82,9 @@ func (op *otsdbProcessor) run(silent, verbose bool) error { errCh := make(chan error) // we're going to make serieslist * queryRanges queries, so we should represent that in the progress bar bar := pb.StartNew(len(serieslist) * queryRanges) + defer func(bar *pb.ProgressBar) { + bar.Finish() + }(bar) var wg sync.WaitGroup wg.Add(op.otsdbcc) for i := 0; i < op.otsdbcc; i++ { diff --git a/app/vmctl/prometheus.go b/app/vmctl/prometheus.go index b5e018c4a..363aa60a6 100644 --- a/app/vmctl/prometheus.go +++ b/app/vmctl/prometheus.go @@ -43,6 +43,7 @@ func (pp *prometheusProcessor) run(silent, verbose bool) error { if err := barpool.Start(); err != nil { return err } + defer barpool.Stop() blockReadersCh := make(chan tsdb.BlockReader) errCh := make(chan error, pp.cc) @@ -89,7 +90,7 @@ func (pp *prometheusProcessor) run(silent, verbose bool) error { for err := range errCh { return fmt.Errorf("import process failed: %s", err) } - barpool.Stop() + log.Println("Import finished!") log.Print(pp.im.Stats()) return nil diff --git a/app/vmctl/vm_native.go b/app/vmctl/vm_native.go index 3c2105b18..85b0a9539 100644 --- a/app/vmctl/vm_native.go +++ b/app/vmctl/vm_native.go @@ -89,6 +89,7 @@ func (p *vmNativeProcessor) run(ctx context.Context) error { log.Printf("error start process bars pool: %s", err) return err } + defer barpool.Stop() w := io.Writer(pw) if p.rateLimit > 0 { @@ -106,7 +107,6 @@ func (p *vmNativeProcessor) run(ctx context.Context) error { } <-sync - barpool.Stop() log.Println("Import finished!") return nil }