#!/bin/bash
# SKEEN — Detener todos los servicios del ecosistema
# Uso: ./skeen-stop-all.sh

echo "=========================================="
echo "Deteniendo ecosistema SKEEN"
echo "=========================================="

# 1. Bridge webhook
pgrep -f "webhook-bridge.js" | xargs -r kill -9 2>/dev/null || true

# 2. Hermes gateway
pgrep -f "hermes gateway run" | xargs -r kill -9 2>/dev/null || true

# 3. Frontend (vite)
pgrep -f "vite" | xargs -r kill -9 2>/dev/null || true

# 4. WACRM (next)
pgrep -f "next-server" | xargs -r kill -9 2>/dev/null || true
pgrep -f "next start" | xargs -r kill -9 2>/dev/null || true

# 5. Odoo
pgrep -f "odoo-bin" | xargs -r kill -9 2>/dev/null || true

# 6. Supabase Docker
cd /root/skeen-supabase/docker 2>/dev/null && docker compose down || echo "Supabase no estaba corriendo o docker no disponible"

echo "=========================================="
echo "Servicios detenidos"
echo "Verifica con: ss -tlnp | grep -E '3000|5173|8069|8000|8090|8644|8080'"
echo "=========================================="
