#!/bin/bash
# Wrapper script for Socket.IO server daemon management.
#
# This script provides a simple command-line interface for managing
# the Socket.IO server daemon that powers the monitoring dashboard.
#
# Usage:
#   claude-mpm-socketio start     - Start the server daemon
#   claude-mpm-socketio stop      - Stop the server daemon
#   claude-mpm-socketio restart   - Restart the server daemon
#   claude-mpm-socketio status    - Check server status

# Get the directory where this script is located
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

# Path to the Python daemon script
DAEMON_SCRIPT="${SCRIPT_DIR}/socketio_daemon.py"

# Check if the daemon script exists
if [ ! -f "$DAEMON_SCRIPT" ]; then
    echo "Error: Socket.IO daemon script not found at $DAEMON_SCRIPT"
    exit 1
fi

# Check if Python is available
if ! command -v python3 &> /dev/null; then
    echo "Error: Python 3 is required but not found"
    exit 1
fi

# Execute the Python daemon with all arguments
exec python3 "$DAEMON_SCRIPT" "$@"