diff --git a/cmd/list-root.go b/cmd/list-root.go index c28856f..0686c01 100644 --- a/cmd/list-root.go +++ b/cmd/list-root.go @@ -62,14 +62,11 @@ func listCmdImpl(cmd *cobra.Command, args []string) { } func listAll(ctx context.Context, client client.AzureClient, panicChan chan error) <-chan interface{} { - ctx, stop := context.WithCancel(ctx) var ( azureAD = listAllAD(ctx, client, panicChan) azureRM = listAllRM(ctx, client, panicChan) ) - handleBubbledPanic(ctx, panicChan, stop) - return pipeline.Mux(ctx.Done(), azureAD, azureRM) } diff --git a/cmd/start.go b/cmd/start.go index e7852a6..685bcc9 100644 --- a/cmd/start.go +++ b/cmd/start.go @@ -150,6 +150,9 @@ func start(ctx context.Context) { start := time.Now() + ctx, stop := context.WithCancel(ctx) + handleBubbledPanic(ctx, panicChan, stop) + // Batch data out for ingestion stream := listAll(ctx, azClient, panicChan) batches := pipeline.Batch(ctx.Done(), stream, 256, 10*time.Second) diff --git a/cmd/utils.go b/cmd/utils.go index 9867489..2781903 100644 --- a/cmd/utils.go +++ b/cmd/utils.go @@ -96,7 +96,6 @@ func panicChan() chan error { // handleBubbledPanic receives errors from panicChan, then it will print them and stop() context. func handleBubbledPanic(ctx context.Context, panicChan chan error, stop context.CancelFunc) { go func() { - for { select { case err := <-panicChan: