#!/usr/bin/env bash # ------------------------------------------------------------------------------ # FILE: vllm-workspace.sh — deployed by roles/deploy-vllm to # /home/{{ vllm_venv_owner }}/vllm-workspace.sh # # Convenience wrapper for manual debugging / smoke-testing the vLLM venv # without having to remember the venv path or model roster each time. # Regenerated on every Ansible run — do not hand-edit, edit the template # instead (roles/deploy-vllm/templates/vllm-workspace.sh.j2). # ------------------------------------------------------------------------------ set -euo pipefail VENV="{{ vllm_venv_path }}" CACHE="{{ vllm_hf_hub_cache }}" API_KEY_FILE="{{ vllm_api_key_env_file }}" usage() { cat < Commands: activate Print the command to source the vLLM venv version Print installed vLLM + torch/CUDA versions models List staged model snapshots in the HF cache curl-models curl /v1/models on each enabled instance (requires sudo to read API key) logs Tail journalctl for a vllm systemd unit (e.g. vllm.service) EOF } case "${1:-}" in activate) echo "source $VENV/bin/activate" ;; version) "$VENV/bin/python" -c 'import vllm, torch; print("vllm", vllm.__version__); print("torch", torch.__version__, "cuda", torch.version.cuda, "available", torch.cuda.is_available())' ;; models) find "$CACHE" -maxdepth 1 -type d -name 'models--*' -printf '%f\n' 2>/dev/null || echo "(no models staged yet)" ;; curl-models) {% for item in vllm_enabled_models | default([]) %} echo "--- {{ item.id }} (:{{ item.port }}) ---" curl -s -H "Authorization: Bearer $(sudo grep -oP '(?<=VLLM_API_KEY=).*' "$API_KEY_FILE")" \ http://127.0.0.1:{{ item.port }}/v1/models | python3 -m json.tool || true {% endfor %} ;; logs) sudo journalctl -u "${2:-vllm.service}" -f ;; *) usage exit 1 ;; esac