#!/bin/bash
# vLLM + LMCacheConnectorV1 alone. Skip if LMCache not installed.
set -euo pipefail
source "$(dirname "${BASH_SOURCE[0]}")/common.sh"

if ! "$PYTHON" -c 'import lmcache' 2>/dev/null; then
    echo "SKIP: lmcache module not importable" >&2
    exit 42
fi

KV_CFG='{"kv_connector":"LMCacheConnectorV1","kv_role":"kv_both"}'

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
