Repository navigation
Expand file tree
/
Copy pathstart.sh
More file actions
48 lines (43 loc) · 1.36 KB
/
Copy pathstart.sh
File metadata and controls
48 lines (43 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
# ================================================
# start.sh — Start the FastAPI server (Linux/Mac)
# ================================================
# Load .env if it exists
if [ -f ".env" ]; then
export $(grep -v '^#' .env | xargs)
echo "✅ Loaded config from .env"
else
echo "⚠️ No .env file found. Copying from .env.example..."
cp .env.example .env
export $(grep -v '^#' .env | xargs)
fi
# Defaults if not set
HOST="${HOST:-0.0.0.0}"
PORT="${PORT:-8000}"
WORKERS="${WORKERS:-1}"
LOG_LEVEL="${LOG_LEVEL:-info}"
echo ""
echo "========================================"
echo " 🚀 FastAPI Server Starting"
echo "========================================"
echo " Host : $HOST"
echo " Port : $PORT"
echo " Workers : $WORKERS"
echo " Log Level: $LOG_LEVEL"
echo "========================================"
echo " 📖 Swagger UI : http://$HOST:$PORT/docs"
echo " 📖 ReDoc : http://$HOST:$PORT/redoc"
echo " ❤️ Health : http://$HOST:$PORT/health"
echo "========================================"
echo ""
# Install dependencies if not installed
if ! python3 -c "import fastapi" 2>/dev/null; then
echo "📦 Installing dependencies..."
pip install -r requirements.txt
fi
# Start with hypercorn
hypercorn main:app \
--bind "$HOST:$PORT" \
--workers "$WORKERS" \
--log-level "$LOG_LEVEL" \
--reload