test: Testinstanz auf srv04 für admin2engineoberflaeche.1 (#1101)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
61
scripts/srv04-engineui-test/remote.sh
Executable file
61
scripts/srv04-engineui-test/remote.sh
Executable file
@ -0,0 +1,61 @@
|
||||
#!/bin/bash
|
||||
# Läuft AUF srv04 als Benutzer stephan (ohne sudo). Testinstanz für die Oberfläche von llama.cpp (admin2engineoberflaeche.1, #1101).
|
||||
# Aufruf: bash remote.sh prepare|start|stop|status|clean
|
||||
# Alles liegt unter /tmp/nexus-test-0129 (tmpfs). Die Produktion (nexus.service, Port 8080) wird nicht angefasst.
|
||||
# `prepare` und `start` laden KEIN Modell. Geladen wird erst im Test (kleines Modell Bonsai, rund 0,6 GB auf GPU 0).
|
||||
set -u
|
||||
DIR=/tmp/nexus-test-0129
|
||||
NEXUS_PORT=18137
|
||||
UI_PORT=18139
|
||||
N="$DIR/bin/nexus"
|
||||
CFG="$DIR/config.toml"
|
||||
M=/srv/models/gguf
|
||||
|
||||
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|@UI_PORT@|$UI_PORT|g" "$DIR/config.toml.in" > "$CFG"
|
||||
[ -s "$CFG" ] || { echo "Konfiguration ist leer: $CFG"; exit 1; }
|
||||
"$N" selftest --config "$CFG" | tail -2
|
||||
"$N" model list --config "$CFG" 2>/dev/null | grep -q '^bonsai' || "$N" model add --name bonsai --path "$M/Bonsai-1.7B-Q1_0.gguf" --gpus 0 --context 2048 --config "$CFG" | tail -1
|
||||
"$N" model enable --name bonsai --config "$CFG" | tail -1
|
||||
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
|
||||
if [ ! -s "$DIR/key.txt" ]; then
|
||||
umask 077
|
||||
"$N" key create --name test --models '*' --config "$CFG" 2>&1 | grep -o 'nx[A-Za-z0-9_-]*\|sk-[A-Za-z0-9_-]*' | head -1 > "$DIR/key.txt"
|
||||
fi
|
||||
echo "Vorbereitet. Benutzer: testadmin, Passwort in $DIR/admin-passwort.txt, Schlüssel in $DIR/key.txt (beide 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
|
||||
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, Oberflächen auf 127.0.0.1:$UI_PORT (PID $(cat "$DIR/nexus.pid")). Tunnel von deinem Rechner: ssh -N -L $NEXUS_PORT:127.0.0.1:$NEXUS_PORT -L $UI_PORT:127.0.0.1:$UI_PORT srv04"
|
||||
;;
|
||||
stop)
|
||||
if [ -f "$DIR/nexus.pid" ]; then kill "$(cat "$DIR/nexus.pid")" 2>/dev/null; rm -f "$DIR/nexus.pid"; fi
|
||||
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 "llama-server-Prozesse:"; ps -eo pid,args | grep "^ *[0-9]* /srv/apps/llama.cpp/build/bin/llama-server" | cut -c1-140
|
||||
echo "GPUs:"; gpus
|
||||
;;
|
||||
clean)
|
||||
bash "$0" stop
|
||||
rm -rf "$DIR"
|
||||
echo "Aufgeräumt. GPUs:"; gpus
|
||||
;;
|
||||
*) echo "Aufruf: remote.sh prepare|start|stop|status|clean"; exit 2;;
|
||||
esac
|
||||
Reference in New Issue
Block a user