implemented step 14 by Gemini

- added LLMpool, worker script
This commit is contained in:
2026-06-14 14:39:51 +02:00
parent ec698f3f34
commit d07bc89eea
5 changed files with 281 additions and 2 deletions

42
scripts/worker.php Normal file
View File

@ -0,0 +1,42 @@
<?php
declare(strict_types=1);
/**
* LLMpool Worker CLI Script
* This script processes the AI generation queue.
*/
require_once __DIR__ . '/../vendor/autoload.php';
// Load configuration from root .env
\App\Utils\Config::load(__DIR__ . '/../.env');
use App\Services\LLMpool;
// Ensure this script is only run from CLI
if (php_sapi_name() !== 'cli') {
die("This script can only be run from the command line." . PHP_EOL);
}
$lockFile = sys_get_temp_dir() . '/webwizard_worker.lock';
$fp = fopen($lockFile, 'w');
if (!flock($fp, LOCK_EX | LOCK_NB)) {
die("[" . date('Y-m-d H:i:s') . "] Worker is already running. Skipping." . PHP_EOL);
}
echo "[" . date('Y-m-d H:i:s') . "] Starting LLMpool worker..." . PHP_EOL;
try {
$worker = new LLMpool();
$worker->processQueue();
} catch (Throwable $e) {
echo "[" . date('Y-m-d H:i:s') . "] FATAL ERROR: " . $e->getMessage() . PHP_EOL;
}
echo "[" . date('Y-m-d H:i:s') . "] Finished LLMpool worker." . PHP_EOL;
flock($fp, LOCK_UN);
fclose($fp);
unlink($lockFile);