#!/bin/bash
set -e

BASE="$(cd "$(dirname "$0")" && pwd)"

echo "Starting pgvector backend (port 8000)..."
cd "$BASE/pgvector-demo/backend"
uvicorn main:app --host 0.0.0.0 --port 8000 &
PID1=$!

echo "Starting Oracle 26ai backend (port 8001)..."
cd "$BASE/oravector-demo/backend"
uvicorn main_oracle:app --host 0.0.0.0 --port 8001 &
PID2=$!

echo "Starting Oracle in-DB backend (port 8002)..."
cd "$BASE/oravector-demo/backend"
uvicorn main_oracle_indb:app --host 0.0.0.0 --port 8002 &
PID3=$!

echo ""
echo "All backends running:"
echo "  http://localhost:8000/ui/  — pgvector"
echo "  http://localhost:8001/ui/  — Oracle 26ai"
echo "  http://localhost:8002/ui/  — Oracle In-DB"
echo ""
echo "Press Ctrl+C to stop all."

trap "kill $PID1 $PID2 $PID3 2>/dev/null; echo 'Stopped.'" EXIT
wait
