#!/usr/bin/env bash
set -euo pipefail

repo_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
python_bin="$repo_dir/server/.venv/bin/python"
if [[ ! -x "$python_bin" ]]; then
    echo "Missing server environment. Run ./scripts/setup-server.sh first." >&2
    exit 1
fi

cd "$repo_dir/server"
exec "$python_bin" -m uvicorn device_gateway.app:app --ws-max-size 8192 --host "${GATEWAY_HOST:-127.0.0.1}" --port "${GATEWAY_PORT:-8000}"
