drush icon indicating copy to clipboard operation
drush copied to clipboard

Add a progress bar to the queue:run command

Open DieterHolvoet opened this issue 1 year ago • 9 comments

Just an idea for a small improvement I had: the queue:run command could use a progress bar, especially in case of large queues.

DieterHolvoet avatar May 05 '24 15:05 DieterHolvoet

If the queue worker logs messages, are they still shown? If so, I think this LGTM

weitzman avatar May 06 '24 19:05 weitzman

I just tested and it looks like Drupal logs are never logged to the console: not with the progress bar, not without.

DieterHolvoet avatar May 06 '24 19:05 DieterHolvoet

One thing we might want to change - not sure though - is to only start a progress bar once the first queue item is processed. What do you think?

CleanShot 2024-05-06 at 21 19 56@2x

DieterHolvoet avatar May 06 '24 19:05 DieterHolvoet

Thanks. I'm also curious about any drush log messages that come from the worker. Maybe thats too uncommon to care about.

The screenshot should also show the total number of items, right? Otherwise progress is a bit hard to understand. Once that is done, we could arguably get rid of the log message that reports progress.

weitzman avatar May 06 '24 19:05 weitzman

Thanks. I'm also curious about any drush log messages that come from the worker. Maybe thats too uncommon to care about.

Here's what that looks like: CleanShot 2024-05-06 at 21 40 02@2x

Multiple logs per queue item: CleanShot 2024-05-06 at 21 40 44@2x

The screenshot should also show the total number of items, right?

It does, except when there's 0 items to be processed, which is why I proposed to not even start the progress bar at all in that case.

DieterHolvoet avatar May 06 '24 19:05 DieterHolvoet

Thats super ugly IMO. Once a progress bar starts repeating lines it loses its value IMO. Happy to discuss more.

weitzman avatar May 06 '24 19:05 weitzman

I agree, but I'm not sure if there's anything straightforward we can do about this. Also haven't tested this yet with Laravel Prompts https://laravel.com/docs/11.x/prompts#progress

DieterHolvoet avatar May 06 '24 20:05 DieterHolvoet

On the other hand, progress bars are also used by the entity:delete and entity:save commands, the same thing could happen there as well. And what would be the alternative? How could we display both a progress bar and a list of messages? I just experimented a bit with console sections, but I can't seem to get it to work for our use case: https://symfony.com/blog/new-in-symfony-4-1-advanced-console-output

DieterHolvoet avatar May 06 '24 21:05 DieterHolvoet

Right, there isnt. a great alternative. And thats why this command hasnt been made a progress bar for years. The other two commands you mention were converted by eager contributors, not me. I merged their PRs because others liked it. I actually dislike progress bars on CLI personally.

weitzman avatar May 07 '24 15:05 weitzman