#!/bin/bash
# vLLM + Mooncake kv_producer (no D peer, never transfers).
set -euo pipefail
source "$(dirname "${BASH_SOURCE[0]}")/common.sh"

BOOTSTRAP_PORT="${BOOTSTRAP_PORT:-8998}"
KV_CFG='{"kv_connector":"MooncakeConnector","kv_role":"kv_producer"}'

VLLM_MOONCAKE_BOOTSTRAP_PORT="$BOOTSTRAP_PORT" \
CUDA_VISIBLE_DEVICES="$GPU_ID" \
"$PYTHON" -m vllm.entrypoints.openai.api_server \
    "${COMMON_VLLM_ARGS[@]}" \
    --kv-transfer-config "$KV_CFG" \
    > "$LOG_DIR/vllm_stdout.log" 2> "$LOG_DIR/vllm_stderr.log" &
VLLM_PID=$!
echo "$VLLM_PID" > "$LOG_DIR/.vllm.pid"
echo "vLLM PID=$VLLM_PID"
wait_for_ready 240
