#!/bin/bash # Antigravity Notebook - Startup Script # This script starts all services needed for Antigravity Notebook set -e echo "======================================" echo "🚀 Antigravity Notebook - Startup" echo "======================================" # Colors for output GREEN='\033[0;32m' YELLOW='\033[1;33m' NC='\033[0m' # No Color # Check if .env exists if [ ! -f .env ]; then echo -e "${YELLOW}⚠️ .env file not found. Creating from .env.example...${NC}" cp .env.example .env echo -e "${GREEN}✅ Created .env file. You may want to customize it.${NC}" fi # Start PostgreSQL echo "" echo "📊 Starting PostgreSQL..." docker-compose up -d # Wait for PostgreSQL to be ready echo "⏳ Waiting for PostgreSQL to be ready..." sleep 5 # Check if database is initialized echo "" echo "🔧 Initializing database..." python -m backend.database # Start backend in background echo "" echo "🖥️ Starting FastAPI backend..." echo " (API will be available at http://localhost:8000)" python -m backend.main & BACKEND_PID=$! # Wait for backend to start sleep 10 # Start frontend echo "" echo "🎨 Starting Streamlit frontend..." echo " (UI will be available at http://localhost:8501)" streamlit run frontend/app_notebook.py & FRONTEND_PID=$! echo "" echo "======================================" echo -e "${GREEN}✅ Antigravity Notebook is running!${NC}" echo "======================================" echo "" echo "📍 Services:" echo " • Frontend UI: http://localhost:8501" echo " • Backend API: http://localhost:8000" echo " • API Docs: http://localhost:8000/docs" echo "" echo "Press Ctrl+C to stop all services" echo "" # Function to cleanup on exit cleanup() { echo "" echo "🛑 Stopping services..." kill $BACKEND_PID 2>/dev/null || true kill $FRONTEND_PID 2>/dev/null || true docker-compose down echo "✅ All services stopped" exit 0 } # Trap Ctrl+C and call cleanup trap cleanup INT TERM # Wait for processes wait