digbang / safe-queue
一个适用于Laravel Doctrine的友好的守护进程化队列工作进程,用于Laravel
v1.1.0
2022-02-25 14:24 UTC
Requires
- php: ^7.4 || ^8.0.2
- illuminate/queue: ^8.0 || ^9.0
- laravel-doctrine/orm: ^1.7
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.6
- mockery/mockery: ^1.5
- phpunit/phpunit: ^8.5 || ^9.5
README
一个安全用于与Laravel Doctrine一起使用的Laravel队列工作进程
何时使用SafeQueue
- 您使用Laravel 6或更高版本
- 您使用Laravel Doctrine
- Devops说
queue:listen
的CPU使用率不可接受 - 您想在没有触发级联
EntityManager is closed
异常的情况下使用php artisan queue:work --daemon
兼容性
工作原理
SafeQueue通过覆盖Laravel功能的一小部分,使得队列工作进程守护程序在使用Doctrine时更加安全。它确保在发生异常后,如果EntityManager被关闭,则工作进程退出。为了万无一失,它还在处理每个工作之前清除EM。
安装
使用composer安装
composer require digbang/safe-queue
一旦您有了代码,请将以下内容添加到app.php
中的服务提供者中
Digbang\SafeQueue\DoctrineQueueProvider::class
Lumen
创建配置文件config/safequeue.php
并加载:$app->configure('safequeue');
<?php
return [
/*
|--------------------------------------------------------------------------
| Worker Command Name
|--------------------------------------------------------------------------
|
| Configure the signature / name of the Work Command here. The default
| is to rename the command to 'doctrine:queue:work', however you can
| rename it to whatever you want by changing this value.
|
| To override the Laravel 'queue:work' command name just set this
| to a false value or 'queue:work'.
|
*/
'command_name' => 'doctrine:queue:work',
];
使用方法
php artisan doctrine:queue:work connection --daemon --sleep=3 --tries=3 ...
所有选项与Laravel自己的queue:work
方法相同。