44 lines
1.3 KiB
PHP
Executable File
44 lines
1.3 KiB
PHP
Executable File
#!/usr/bin/env php
|
|
<?php
|
|
// scripts/start_worker_pool.php
|
|
// Script para iniciar el pool de workers de traducción
|
|
|
|
// Permitir ejecución indefinida
|
|
set_time_limit(0);
|
|
|
|
// Verificar que se ejecuta desde CLI
|
|
if (php_sapi_name() !== 'cli') {
|
|
die("Este script solo puede ejecutarse desde la línea de comandos.\n");
|
|
}
|
|
|
|
// Cargar configuración
|
|
require_once __DIR__ . '/../config/config.php';
|
|
require_once __DIR__ . '/../includes/db.php';
|
|
require_once __DIR__ . '/../includes/logger.php';
|
|
require_once __DIR__ . '/../src/TranslationWorkerPool.php';
|
|
|
|
custom_log("=== INICIANDO POOL DE WORKERS DE TRADUCCIÓN ===");
|
|
custom_log("Environment: " . (getenv('APP_ENVIRONMENT') ?: 'default'));
|
|
custom_log("PID del proceso principal: " . getmypid());
|
|
|
|
try {
|
|
// Verificar que PCNTL está disponible
|
|
if (!function_exists('pcntl_fork')) {
|
|
throw new Exception("La extensión PCNTL no está disponible. Instala php-pcntl.");
|
|
}
|
|
|
|
// Crear pool de workers
|
|
$pool = new TranslationWorkerPool($pdo);
|
|
|
|
// Iniciar pool (esto bloqueará hasta que se detenga)
|
|
$pool->start();
|
|
|
|
} catch (Exception $e) {
|
|
custom_log("ERROR FATAL: " . $e->getMessage());
|
|
custom_log("Stack trace: " . $e->getTraceAsString());
|
|
exit(1);
|
|
}
|
|
|
|
custom_log("=== POOL DE WORKERS DETENIDO ===");
|
|
exit(0);
|