43 lines
1.2 KiB
PHP
43 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use Illuminate\Console\Command;
|
|
|
|
/**
|
|
* Dev-friendly alternative to `workerman:ai`.
|
|
*
|
|
* Does NOT start Workerman. It only wraps Laravel's `queue:work` for the
|
|
* AI queues so local setups without pcntl/posix/PM2 can still drain jobs.
|
|
*/
|
|
class QueueAiWorkCommand extends Command
|
|
{
|
|
protected $signature = 'queue:ai
|
|
{--once : Process available jobs once and exit}
|
|
{--max-time=60 : Max seconds when looping}';
|
|
|
|
protected $description = 'Drain ai-content/ai-moderation via queue:work (does not start Workerman; use workerman:ai for that)';
|
|
|
|
public function handle(): int
|
|
{
|
|
$this->comment('queue:ai → Laravel queue:work (not Workerman). For a long-lived Workerman process use: php artisan workerman:ai start');
|
|
|
|
$params = [
|
|
'--queue' => 'ai-content,ai-moderation',
|
|
'--tries' => 3,
|
|
'--sleep' => 1,
|
|
];
|
|
|
|
if ($this->option('once')) {
|
|
$params['--stop-when-empty'] = true;
|
|
$params['--max-jobs'] = 50;
|
|
} else {
|
|
$params['--max-time'] = (int) $this->option('max-time');
|
|
}
|
|
|
|
return $this->call('queue:work', $params);
|
|
}
|
|
}
|