You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.5 KiB
52 lines
1.5 KiB
#!/usr/bin/env bash
|
|
# scripts/start.sh — Bootstrap and start the Second Brain stack.
|
|
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
ROOT="$SCRIPT_DIR/.."
|
|
|
|
cd "$ROOT"
|
|
|
|
echo "🧠 AI Second Brain — startup"
|
|
|
|
# Ensure .env exists
|
|
if [ ! -f .env ]; then
|
|
echo " → Creating .env from .env.example"
|
|
cp .env.example .env
|
|
echo " ⚠️ Edit .env before production use (set POSTGRES_PASSWORD etc.)"
|
|
fi
|
|
|
|
# Ensure vault directory exists
|
|
mkdir -p vault
|
|
|
|
echo " → Starting Docker services..."
|
|
docker compose up -d --build
|
|
|
|
echo " → Waiting for services to be healthy..."
|
|
sleep 5
|
|
|
|
# Poll health endpoint
|
|
MAX_ATTEMPTS=30
|
|
ATTEMPT=0
|
|
until curl -sf http://localhost:8000/api/v1/health > /dev/null 2>&1; do
|
|
ATTEMPT=$((ATTEMPT + 1))
|
|
if [ "$ATTEMPT" -ge "$MAX_ATTEMPTS" ]; then
|
|
echo " ✗ API did not become healthy after ${MAX_ATTEMPTS} attempts."
|
|
echo " Check logs with: docker compose logs rag-api"
|
|
exit 1
|
|
fi
|
|
echo " ... waiting for API (${ATTEMPT}/${MAX_ATTEMPTS})"
|
|
sleep 5
|
|
done
|
|
|
|
echo ""
|
|
echo " ✓ Second Brain is running!"
|
|
echo ""
|
|
echo " 🌐 Web UI: http://localhost:$(grep UI_PORT .env | cut -d= -f2 || echo 3000)"
|
|
echo " 🔌 RAG API: http://localhost:$(grep API_PORT .env | cut -d= -f2 || echo 8000)"
|
|
echo " 📖 API Docs: http://localhost:$(grep API_PORT .env | cut -d= -f2 || echo 8000)/docs"
|
|
echo " 🤖 Ollama: http://localhost:$(grep OLLAMA_PORT .env | cut -d= -f2 || echo 11434)"
|
|
echo ""
|
|
echo " Run 'docker compose logs -f' to follow logs."
|