#!/bin/bash # Define paths PROJECT_ROOT=$(pwd) PID_FILE="$PROJECT_ROOT/.server_manager.pids" # Function to start Huey Consumer start_huey() { echo "Starting Huey Consumer..." # Activate venv from PROJECT_ROOT if [ -d "$PROJECT_ROOT/venv" ]; then source "$PROJECT_ROOT/venv/bin/activate" elif [ -d "$PROJECT_ROOT/.venv" ]; then source "$PROJECT_ROOT/.venv/bin/activate" fi cd "$PROJECT_ROOT/backend" # Run huey consumer in background huey_consumer.py app.tasks.huey > ../logs/huey.log 2>&1 & HUEY_PID=$! echo $HUEY_PID >> "$PID_FILE" echo "Huey started (PID: $HUEY_PID). Logs: logs/huey.log" } # Function to start backend start_backend() { echo "Starting Backend..." # Activate venv from PROJECT_ROOT if [ -d "$PROJECT_ROOT/venv" ]; then source "$PROJECT_ROOT/venv/bin/activate" elif [ -d "$PROJECT_ROOT/.venv" ]; then source "$PROJECT_ROOT/.venv/bin/activate" fi cd "$PROJECT_ROOT/backend" # Run uvicorn in background # Redirecting output to logs or /dev/null is often cleaner, but for now we keep it visible or rely on user uvicorn app.main:app --reload --host 0.0.0.0 --port 8000 > ../logs/backend.log 2>&1 & BACKEND_PID=$! echo $BACKEND_PID >> "$PID_FILE" echo "Backend started (PID: $BACKEND_PID). Logs: logs/backend.log" } # Function to start frontend start_frontend() { echo "Starting Frontend..." cd "$PROJECT_ROOT/frontend" npm run dev -- --host --port 5173 > ../logs/frontend.log 2>&1 & FRONTEND_PID=$! echo $FRONTEND_PID >> "$PID_FILE" echo "Frontend started (PID: $FRONTEND_PID). Logs: logs/frontend.log" } # Ensure log directory exists mkdir -p "$PROJECT_ROOT/logs" # Clear old pid file if it exists if [ -f "$PID_FILE" ]; then echo "Warning: .server_manager.pids exists. Clearing..." rm "$PID_FILE" fi start_huey start_backend start_frontend echo "Application started." echo "Backend: http://localhost:8000" echo "Frontend: http://localhost:5173"