Captures the current working tree after theme slots, ArticleAccess, and the payment / paid-content plugins so subsequent work has a reviewable git history.
49 lines
1.3 KiB
PHP
49 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use Illuminate\Console\Command;
|
|
use Illuminate\Support\Facades\Artisan;
|
|
use Workerman\Timer;
|
|
use Workerman\Worker;
|
|
|
|
/**
|
|
* Long-lived Workerman process for AI queues (content optimize + comment moderation).
|
|
*/
|
|
class WorkermanAiCommand extends Command
|
|
{
|
|
protected $signature = 'workerman:ai {--count=1 : Worker processes}';
|
|
|
|
protected $description = 'Start Workerman workers that process ai-content and ai-moderation queues';
|
|
|
|
public function handle(): int
|
|
{
|
|
$this->info('Starting Workerman AI runtime (queues: ai-content, ai-moderation)...');
|
|
|
|
Worker::$pidFile = storage_path('logs/workerman-ai.pid');
|
|
Worker::$logFile = storage_path('logs/workerman-ai.log');
|
|
|
|
$worker = new Worker();
|
|
$worker->count = max(1, (int) $this->option('count'));
|
|
$worker->name = 'larablog-ai';
|
|
|
|
$worker->onWorkerStart = function () {
|
|
Timer::add(1, function () {
|
|
Artisan::call('queue:work', [
|
|
'--queue' => 'ai-content,ai-moderation',
|
|
'--stop-when-empty' => true,
|
|
'--max-time' => 50,
|
|
'--sleep' => 1,
|
|
'--tries' => 3,
|
|
]);
|
|
});
|
|
};
|
|
|
|
Worker::runAll();
|
|
|
|
return self::SUCCESS;
|
|
}
|
|
}
|