Package Data | |
---|---|
Maintainer Username: | web-chefs |
Package Create Date: | 2017-08-25 |
Package Last Update: | 2021-05-07 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2025-02-06 03:07:29 |
Package Statistics | |
---|---|
Total Downloads: | 4,762 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 14 |
Total Watchers: | 4 |
Total Forks: | 2 |
Total Open Issues: | 0 |
Laravel Artisan commands that make it easy to run job queues using the Scheduler without the need for installing for running the Queue Daemon or installing Supervisor.
This is ideal for shared hosting or situations where you are not fully in control of the services or management of your hosting infrastructure and all you have access to is a Cron.
Confirmed to be working:
Via Composer
$ composer require web-chefs/queue-butler
Add Service Provider to config/app.php
'providers' => [
// Other Service Providers
WebChefs\QueueButler\QueueButlerServiceProvider::class,
];
Run queue:batch
artisan command, supports many of the same options as queue:work
. Two additional options time-limit
in seconds (defaults to 60 seconds) and 'job-limit' (defaults to 100) need to be set based on your Scheduling setup.
Example:
Run batch for 4 min 30 seconds or 1000 jobs, then stop.
artisan queue:batch --time-limit=270 --job-limit=1000
In your App\Console\Kernel.php
in the schedule()
method add your queue:batch
commands.
Example:
Run batch every minute for 50 seconds or 100 jobs in the background using runInBackground()
, then stop.
Prevent overlapping batches running simultaneously with withoutOverlapping()
.
$schedule->command('queue:batch --queue=default,something,somethingelse --time-limit=50 --job-limit=100')
->everyMinute()
->runInBackground()
->withoutOverlapping();
If your application is processing a large number of jobs for multiple queues, it is recommended setting up different batch scheduler commands per queue.
Because job queue processing is a long running process setting runInBackground()
is highly recommended, else each queue:batch
command will hold up all scheduled preceding items setup to run after it.
The Scheduler requires a Cron to be setup. See Laravel documentation for details how the Scheduler works.
withoutOverlapping()
and Mutex cache expiry
When using withoutOverlapping()
a cache Mutex is used to keep track of running jobs. The default cache expiry is 1440 minutes (24 hours).
If your batch process is interrupted the scheduler will ignore the task for the time of the expiry and you will have no jobs processing for 24 hours. The only way to resolve this is to clear the cache or manually remove the batch processes cache entry.
To prevent long running cache expiries it is advised to match your cache cache expiry time with your task frequency.
// Create Batch Job Queue Processor Task
$scheduledEvent = $schedule->command('queue:batch --queue=default,something,somethingelse --time-limit=55 --job-limit=100');
// Match cache expiry with frequency
// Set cache mutex expiry to One min (default is 1440)
$scheduledEvent->expiresAt = 1;
$scheduledEvent->everyMinute()
->withoutOverlapping()
->runInBackground();
Please see CHANGELOG for more information on what has changed recently.
All code submissions will only be evaluated and accepted as pull-requests. If you have any questions or find any bugs please feel free to open an issue.
The MIT License (MIT). Please see License File for more information.