File size: 1,942 Bytes
b4856f1 |
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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
#!/bin/bash
# start_services.sh
# Start all ModelX Anomaly Detection services in proper order
echo "==================================================="
echo "🚀 Starting ModelX Anomaly Detection Pipeline"
echo "==================================================="
# Get script directory
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
cd "$SCRIPT_DIR"
# 1. Check for dependencies
echo "[1/3] Checking dependencies..."
if [ ! -f "models/anomaly-detection/models_cache/lid.176.bin" ]; then
echo "⚠️ WARNING: FastText model not found in models/anomaly-detection/models_cache/"
echo " Please download it from: https://dl.fbaipublicfiles.com/fasttext/supervised-models/lid.176.bin"
fi
# 2. Start Vectorization API (Background)
echo "[2/3] Starting Vectorization Agent API..."
echo " - Port: 8001"
echo " - Log: vectorization_api.log"
# Use nohup to run in background
nohup python src/api/vectorization_api.py > vectorization_api.log 2>&1 &
API_PID=$!
echo " ✅ API started with PID: $API_PID"
# Wait for API to be ready
echo " ⏳ Waiting for API to initialize..."
sleep 5
# 3. Start Airflow (Astro)
echo "[3/3] Starting Apache Airflow (Astro)..."
echo " - Dashboard: http://localhost:8080"
echo " - DAGs: models/anomaly-detection/dags"
cd models/anomaly-detection
# Check if astro is installed
if ! command -v astro &> /dev/null; then
echo "❌ Error: 'astro' command not found. Please install Astronomer CLI."
echo " Skipping Airflow, but API is still running."
echo ""
echo "Press Ctrl+C to stop the API..."
wait $API_PID
exit 1
fi
# Check if it's an Astro project
if [ ! -f "Dockerfile" ]; then
echo "⚠️ Astro project not initialized. Running 'astro dev init'..."
astro dev init --name anomaly-detection
fi
# Start Astro
astro dev start --no-browser
# Cleanup on exit
echo ""
echo "🛑 Stopping services..."
kill $API_PID 2>/dev/null
echo "✅ Services stopped."
|