Files
larablog/app/Console/Commands/QueueAiWorkCommand.php
T
ak 263b98b218 Initial baseline: LaraBlog core with plugin commerce surface.
Captures the current working tree after theme slots, ArticleAccess, and the payment / paid-content plugins so subsequent work has a reviewable git history.
2026-08-12 01:15:38 +08:00

38 lines
963 B
PHP

<?php
declare(strict_types=1);
namespace App\Console\Commands;
use Illuminate\Console\Command;
/**
* Simple alternative to workerman:ai for local/dev: drain AI queues once or loop.
*/
class QueueAiWorkCommand extends Command
{
protected $signature = 'queue:ai
{--once : Process available jobs once and exit}
{--max-time=60 : Max seconds when looping}';
protected $description = 'Process ai-content and ai-moderation queues (dev-friendly alternative to workerman:ai)';
public function handle(): int
{
$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);
}
}