Files
sistema_funcionando_lastwar/scripts/stop_workers.sh

47 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
# scripts/stop_workers.sh
# Detener todos los workers de traducción
echo "Deteniendo workers de traducción..."
# Buscar y matar el proceso del pool
POOL_PID=$(ps aux | grep "[s]tart_worker_pool.php" | awk '{print $2}')
if [ -n "$POOL_PID" ]; then
echo "Deteniendo pool (PID: $POOL_PID)..."
kill -TERM $POOL_PID
sleep 2
# Verificar si terminó
if ps -p $POOL_PID > /dev/null 2>&1; then
echo "Pool no respondió a SIGTERM, enviando SIGKILL..."
kill -9 $POOL_PID
fi
echo "✓ Pool detenido"
else
echo "No se encontró pool activo"
fi
# Verificar workers huérfanos
ORPHAN_WORKERS=$(ps aux | grep "[T]ranslationWorker" | awk '{print $2}')
if [ -n "$ORPHAN_WORKERS" ]; then
echo "Deteniendo workers huérfanos..."
echo "$ORPHAN_WORKERS" | xargs kill -TERM
sleep 1
echo "✓ Workers huérfanos detenidos"
fi
# Verificar que no queden procesos
REMAINING=$(ps aux | grep -c "[T]ranslation")
if [ $REMAINING -eq 0 ]; then
echo "✓ Todos los workers detenidos correctamente"
exit 0
else
echo "⚠ Advertencia: Aún hay $REMAINING procesos de traducción activos"
ps aux | grep "[T]ranslation"
exit 1
fi