0
votes

For testing purposes, I'm queuing jobs in a queue. And I have opened on another side a command line where I execute:

php artisan queue:work

The above command keeps listening and running on the terminal until I manually kill it.

Since I'm testing singularly Jobs from the queue. It would be very nice to have the command to execute one ore more entries and exit instead of being executed as a daemon and have to kill it somehow...

Also consider that, It's not possible to edit code and have the current execution of queue:work getting the updates without restarting the daemon-ized command.

3

3 Answers

5
votes

You are looking for php artisan queue:work --once, where --once will process the next available job on the queue and then quit. If there are no available jobs it will sleep (default is 3 seconds) and then quit.

There's also php artisan queue:listen which executes the above command in a loop, which means it will pick up on your code changes without manual interference.

-2
votes

Currently there is no such command as far as I know. You can try using the sync queue driver for testing.

-2
votes

use

php artisan queue:work --tries=3

which tries 3 times to execute that