dev-master
9999999-devlaravel graceful exit queue
MIT
The Requires
Wallogit.com
2017 © Pedro Peláez
laravel graceful exit queue
laravel graceful exit queue, (*1)
The recommanded method to graceful restart a queue is using these commands, (*2)
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., (*3)
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., (*4)
You can install with composer, (*5)
composer reqiure lekongkong/lgequeue, (*6)
Please replace the queue service provider, done., (*7)
Add this config sample to your queue.php config file., (*8)
'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., (*9)
'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.laravel graceful exit queue
MIT