#!/bin/bash
# CPU llama-server (端口8126) + 全量本地臂 v4 协议
set -x
LD_LIBRARY_PATH=/opt/qwen-llm/bin /opt/qwen-llm/bin/llama-server \
  -m /mnt/storage/models/Qwen3.8-27B-GGUF/Qwen3.8-27B-UD-Q3_K_XL.gguf \
  --mmproj /mnt/storage/models/Qwen3.8-27B-GGUF/mmproj-F16.gguf \
  -ngl 0 -c 16384 -np 1 --port 8126 \
  --chat-template-kwargs '{"enable_thinking": true}' \
  > /tmp/llama_server_cpu.log 2>&1 &
SERVER_PID=$!
echo "server pid $SERVER_PID"
# 等健康
for i in $(seq 1 90); do
  curl -s -m 2 http://127.0.0.1:8126/health >/dev/null 2>&1 && break
  sleep 10
done
curl -s -m 2 http://127.0.0.1:8126/health && echo " SERVER_READY" || { echo "SERVER_FAIL"; kill $SERVER_PID; exit 1; }
cd /home/kai/shared/qwen-eye-exp
python3 judge_v4_local.py 2>&1
RC=$?
kill $SERVER_PID 2>/dev/null
echo "JUDGE_RC=$RC"
