#!/usr/bin/env bash
set -e

cd "$(dirname "$0")"

# Raise FD limit. With ~242 daemon.conns relays + up to ~256×3 LiveSub WSes,
# the default soft limit of 1024 is hit quickly and new connect()s fail with
# EMFILE — daemon then treats every relay as dead and spins the CPU on retry.
# Hard limit is already ~1M so 64k is comfortably safe.
ulimit -n 65536

if [ ! -d ".venv" ]; then
  python3 -m venv .venv
fi

.venv/bin/pip install -r requirements.txt
exec .venv/bin/python mcp_admin.py
