test: Testinstanz für den Engines-Leitstand auf srv04 (Skripte, Studio-Attrappe, Anleitung; #1198)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-27 09:53:33 +01:00
parent 33720e7c1a
commit 9b7d476c2b
6 changed files with 163 additions and 0 deletions

View File

@ -0,0 +1,64 @@
#!/bin/bash
# Läuft AUF srv04 als Benutzer stephan (ohne sudo). Testinstanz für den Engines-Leitstand (#1198).
# Aufruf: bash remote.sh prepare|start|stop|status|clean
# Alles liegt unter /tmp/nexus-test-0126 (tmpfs). Die Produktion (nexus.service, Port 8080) wird nicht angefasst.
set -u
DIR=/tmp/nexus-test-0126
NEXUS_PORT=18096
STUDIO_PORT=18199
UNIT=nexus-test-studio.service
N="$DIR/bin/nexus"
CFG="$DIR/config.toml"
gpus() { nvidia-smi --query-gpu=index,memory.used,memory.total --format=csv,noheader; }
case "${1:-}" in
prepare)
[ -x "$N" ] || { echo "Binary fehlt: $N"; exit 1; }
mkdir -p "$DIR/data"
sed -e "s|@DIR@|$DIR|g" -e "s|@NEXUS_PORT@|$NEXUS_PORT|g" -e "s|@STUDIO_PORT@|$STUDIO_PORT|g" "$DIR/config.toml.in" > "$CFG"
sed -e "s|@DIR@|$DIR|g" -e "s|@PORT@|$STUDIO_PORT|g" "$DIR/nexus-test-studio.service" > "$DIR/$UNIT"
systemctl --user link "$DIR/$UNIT" && systemctl --user daemon-reload
"$N" selftest --config "$CFG" | tail -2
# Modelle: Bonsai (klein) auf GPU 0 mit kleinem Kontext, freigegeben
"$N" model add --name bonsai --path /srv/models/gguf/Bonsai-1.7B-Q1_0.gguf --gpus 0 --context 2048 --config "$CFG" | tail -1
"$N" model enable --name bonsai --config "$CFG" | tail -1
# Benutzer für die Oberfläche: Passwort nur in eine Datei (0600), nie in die Ausgabe
if ! "$N" user list --config "$CFG" 2>/dev/null | grep -q '^testadmin'; then
umask 077
"$N" user create --name testadmin --role admin --config "$CFG" 2>&1 | grep -i 'passwort' | sed 's/.*: *//' > "$DIR/admin-passwort.txt"
fi
echo "Vorbereitet. Benutzer: testadmin, Passwort in $DIR/admin-passwort.txt (0600)."
;;
start)
[ -f "$CFG" ] || { echo "erst prepare"; exit 1; }
if [ -f "$DIR/nexus.pid" ] && kill -0 "$(cat "$DIR/nexus.pid")" 2>/dev/null; then echo "läuft schon (PID $(cat "$DIR/nexus.pid"))"; exit 0; fi
systemctl --user start "$UNIT"
setsid nohup "$N" serve --config "$CFG" > "$DIR/serve.log" 2>&1 < /dev/null &
echo $! > "$DIR/nexus.pid"
for i in 1 2 3 4 5 6 7 8 9 10; do
curl -s -m 2 "http://127.0.0.1:$NEXUS_PORT/gateway/v1/health" && { echo; break; }
sleep 1
done
echo "Testinstanz auf 127.0.0.1:$NEXUS_PORT (PID $(cat "$DIR/nexus.pid")). Tunnel von deinem Rechner: ssh -N -L 18096:127.0.0.1:18096 srv04"
;;
stop)
if [ -f "$DIR/nexus.pid" ]; then kill "$(cat "$DIR/nexus.pid")" 2>/dev/null; rm -f "$DIR/nexus.pid"; fi
systemctl --user stop "$UNIT" 2>/dev/null
echo "Gestoppt. GPUs:"; gpus
;;
status)
echo "Nexus-Test:"; curl -s -m 2 "http://127.0.0.1:$NEXUS_PORT/gateway/v1/health" || echo "antwortet nicht"; echo
echo "Attrappen-Studio ($UNIT):"; systemctl --user is-active "$UNIT"
echo "Studio-Antwort:"; curl -s -m 2 "http://127.0.0.1:$STUDIO_PORT/studio/status" || echo "antwortet nicht"; echo
echo "llama-server-Prozesse der Testinstanz:"; pgrep -af "^/srv/apps/llama.cpp/build/bin/llama-server" | cut -c1-120 || true
echo "GPUs:"; gpus
;;
clean)
bash "$0" stop
systemctl --user disable "$UNIT" 2>/dev/null; systemctl --user daemon-reload
rm -rf "$DIR"
echo "Aufgeräumt. GPUs:"; gpus
;;
*) echo "Aufruf: remote.sh prepare|start|stop|status|clean"; exit 2;;
esac