#!/bin/bash
# ═══════════════════════════════════════════════════════════
# 🐍 OPHION - Entrypoint
# ═══════════════════════════════════════════════════════════

set -e

MODE=${1:-all}

echo "🐍 OPHION starting in mode: $MODE"

case "$MODE" in
    server)
        echo "Starting API server on port ${SERVER_PORT:-8080}..."
        exec /app/bin/ophion-server
        ;;
    agent)
        echo "Starting agent..."
        exec /app/bin/ophion-agent -config /app/configs/agent.yaml
        ;;
    web)
        echo "Starting dashboard on port ${DASHBOARD_PORT:-3000}..."
        cd /app/web
        exec npm start
        ;;
    all)
        echo "Starting all services..."
        # Start server in background
        /app/bin/ophion-server &
        # Start web
        cd /app/web && npm start
        ;;
    *)
        echo "Unknown mode: $MODE"
        echo "Usage: entrypoint.sh [server|agent|web|all]"
        exit 1
        ;;
esac
