2025-05-24 18:35:10 +02:00

48 lines
1.1 KiB
Bash

#!/bin/bash
# Function to handle cleanup on exit
cleanup() {
echo ""
echo "Shutting down server..."
if [ ! -z "$SERVER_PID" ]; then
kill $SERVER_PID 2>/dev/null
wait $SERVER_PID 2>/dev/null
fi
echo "Server stopped."
exit 0
}
# Set up signal handlers
trap cleanup SIGINT SIGTERM
# Activate virtual environment based on platform
if [ -d "venv" ]; then
if [ -f "venv/Scripts/activate" ]; then
# Windows with Git Bash
source venv/Scripts/activate
else
# Linux/macOS
source venv/bin/activate
fi
echo "Virtual environment activated"
else
echo "WARNING: Virtual environment not found!"
fi
# Set development environment variables
export ENVIRONMENT=development
export LOG_LEVEL=DEBUG
# Start server in development mode with hot reloading
echo "Starting development server..."
echo "Press Ctrl+C to stop the server"
echo "Server will be available at: http://localhost:8000"
echo "API documentation: http://localhost:8000/docs"
echo ""
# Start uvicorn in background and capture PID
uvicorn main:app --host 0.0.0.0 --port 8000 --reload &
SERVER_PID=$!
# Wait for the server process
wait $SERVER_PID