Package Data | |
---|---|
Maintainer Username: | jswh |
Package Create Date: | 2016-07-04 |
Package Last Update: | 2016-07-05 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2025-02-09 15:04:44 |
Package Statistics | |
---|---|
Total Downloads: | 6 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 0 |
Total Watchers: | 1 |
Total Forks: | 0 |
Total Open Issues: | 0 |
laravel graceful exit queue
The recommanded method to graceful restart a queue is using these commands
php artisan down
php artisan queue:restart
But, sometimes, we still want the queue to autoexit when necessary. For example, our team using docker to deploy the software want to determine the queue worker has finished current job and stop doing anything before we remove the old version and deploy a new one.
When some queue has more jobs than others, it may be good to set it to an indenpendent process. We make a new artisan command to make such complex supervisor configurations.
You can install with composer
composer reqiure lekongkong/lgequeue
Please replace the queue service provider, done.
Add this config sample to your queue.php
config file.
'supervisor' => [
//the dir to put logs of supervisor and jobs
'logs' => '/var/logs',
//the artisan file path
'artisan' => '/path/to/artisan',
// the dir where you store jobs
'jobs' => '/path/to/Jobs',
//jobs in one group will be put in one processes
'groups' => [
[
'jobs' => [\app\Jobs\SendPush::class],
],
[
'jobs' => [\app\Jobs\AfterAdSaved::class, \app\Jobs\SelectAd::class, \app\Jobs\SendChatMessage::class],
'processNum' => 1,
],
],
],
you may add a new config handler
to failed
in queue.php
, which will enable your own failed job provider.
'failed' => [
'handler' => \LgeQueue\FailedJobProvider::class
],
php artisan superconf > supervisor.conf
supervisord -c supervisord.conf
php artisan down
Job
class of this repo rather than the original one, which containing a convenient method onSelf
to push the job to the queue named by its class. Otherwise you may have to adjust the groups
config to add your own queue name, not the class name as in sample.queue.php
.