Files
larablog/app/Console/Commands/QueueAiWorkCommand.php
T
gouki 3cec4c5e18
CI / PHPUnit (PHP 8.3) (push) Failing after 4s
CI / PHPUnit (PHP 8.2) (push) Failing after 1m9s
CI / Deploy (manual gate) (push) Skipped
wip: article AI polish, category SEO fields, cover generator, membership plan seeder
2026-09-07 18:48:37 +00:00

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);
}
}