Skip to content

Commit 58bafa2

Browse files
wip: add script
1 parent 799c0ab commit 58bafa2

1 file changed

Lines changed: 82 additions & 0 deletions

File tree

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# -----------------------------
5+
# Configuration
6+
# -----------------------------
7+
PORT=8000
8+
HOST=127.0.0.1
9+
LOG_FILE="vllm.log"
10+
DATASET_ID=""
11+
MODEL="/data/${DATASET_ID}"
12+
TP_SIZE=4
13+
GPUS="0,1,2,3"
14+
15+
SERVER_PID=""
16+
17+
# -----------------------------
18+
# Cleanup handler
19+
# -----------------------------
20+
cleanup() {
21+
if [[ -n "${SERVER_PID}" ]] && kill -0 "${SERVER_PID}" 2>/dev/null; then
22+
echo "Cleaning up vLLM server (PID ${SERVER_PID})..."
23+
kill "${SERVER_PID}"
24+
wait "${SERVER_PID}" 2>/dev/null || true
25+
fi
26+
}
27+
28+
trap cleanup EXIT INT TERM
29+
30+
# -----------------------------
31+
# Start server in background
32+
# -----------------------------
33+
echo "Starting vLLM server..."
34+
35+
CUDA_VISIBLE_DEVICES=${GPUS} \
36+
nohup python -m vllm.entrypoints.openai.api_server \
37+
--model "${MODEL}" \
38+
--tensor-parallel-size "${TP_SIZE}" \
39+
--host 0.0.0.0 \
40+
--port "${PORT}" \
41+
> "${LOG_FILE}" 2>&1 &
42+
43+
SERVER_PID=$!
44+
echo "vLLM server PID: ${SERVER_PID}"
45+
46+
# -----------------------------
47+
# Wait for server readiness
48+
# -----------------------------
49+
echo "Waiting for server to become ready..."
50+
51+
for i in {1..60}; do
52+
if curl -sf "http://${HOST}:${PORT}/v1/models" > /dev/null; then
53+
echo "Server is up!"
54+
break
55+
fi
56+
sleep 1
57+
done
58+
59+
if ! curl -sf "http://${HOST}:${PORT}/v1/models" > /dev/null; then
60+
echo "ERROR: Server did not start within timeout"
61+
echo "Last 50 log lines:"
62+
tail -n 50 "${LOG_FILE}"
63+
exit 1
64+
fi
65+
66+
# -----------------------------
67+
# Curl a test request
68+
# -----------------------------
69+
echo "Sending test completion request..."
70+
71+
curl -s "http://${HOST}:${PORT}/v1/chat/completions" \
72+
-H "Content-Type: application/json" \
73+
-H "Authorization: Bearer test" \
74+
-d "{
75+
\"model\": \"${MODEL}\",
76+
\"messages\": [
77+
{\"role\": \"user\", \"content\": \"Hello from the same machine\"}
78+
]
79+
}" | jq .
80+
81+
echo "Done."
82+
echo "Logs: ${LOG_FILE}"

0 commit comments

Comments
 (0)