#!/bin/bash
cd "/Users/luisachagas/Documents/TOTALFIX/SITE TOTALFIX" || exit 1
echo "Hub de produtos TotalFix — porta 8790"
echo "Pasta: $(pwd)"
echo ""
# Abre o navegador quando o health responder
(
  for i in $(seq 1 30); do
    if curl -sf "http://localhost:8790/api/health" >/dev/null 2>&1; then
      open "http://localhost:8790"
      break
    fi
    sleep 0.5
  done
) &
exec node scripts/hub-produtos-server.mjs
