From f8015ba547f1693bcf9dfbaf62b54692ad599b6a Mon Sep 17 00:00:00 2001 From: wlkns-dev Date: Fri, 27 Nov 2026 16:53:10 +0100 Subject: [PATCH] =?UTF-8?q?test:=20Testinstanz=20auf=20srv04=20f=C3=BCr=20?= =?UTF-8?q?admin2engineoberflaeche.1=20(#1101)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 5.5 --- scripts/srv04-engineui-test/config.toml.in | 9 ++++ scripts/srv04-engineui-test/deploy.sh | 13 +++++ scripts/srv04-engineui-test/remote.sh | 61 ++++++++++++++++++++++ 3 files changed, 83 insertions(+) create mode 100644 scripts/srv04-engineui-test/config.toml.in create mode 100755 scripts/srv04-engineui-test/deploy.sh create mode 100755 scripts/srv04-engineui-test/remote.sh diff --git a/scripts/srv04-engineui-test/config.toml.in b/scripts/srv04-engineui-test/config.toml.in new file mode 100644 index 0000000..db9fbfa --- /dev/null +++ b/scripts/srv04-engineui-test/config.toml.in @@ -0,0 +1,9 @@ +# Testinstanz für die Engine-Oberfläche (#1101), nur 127.0.0.1, Daten unter @DIR@/data. Produktion bleibt unberührt. +listen = "127.0.0.1:@NEXUS_PORT@" +engine_ui_listen = "127.0.0.1:@UI_PORT@" +data_dir = "@DIR@/data" +log_level = "info" + +[llama_cpp] +binary = "/srv/apps/llama.cpp/build/bin/llama-server" +model_roots = ["/srv/models/gguf"] diff --git a/scripts/srv04-engineui-test/deploy.sh b/scripts/srv04-engineui-test/deploy.sh new file mode 100755 index 0000000..54d15f6 --- /dev/null +++ b/scripts/srv04-engineui-test/deploy.sh @@ -0,0 +1,13 @@ +#!/bin/bash +# Läuft auf dem Entwicklungsrechner: kopiert das musl-Binary und die Testdateien nach srv04 und führt `prepare` aus. +# Startet nichts und lädt kein Modell. Aufruf: scripts/srv04-engineui-test/deploy.sh (HOST überschreibbar, Standard 192.168.12.4) +set -eu +HOST="${HOST:-192.168.12.4}" +HIER="$(cd "$(dirname "$0")" && pwd)" +BIN="$HIER/../../target/x86_64-unknown-linux-musl/release/nexus" +[ -x "$BIN" ] || { echo "Binary fehlt: $BIN (cargo build --release --target x86_64-unknown-linux-musl -p nexus)"; exit 1; } +ssh "$HOST" 'bash /tmp/nexus-test-0129/remote.sh stop >/dev/null 2>&1 || true; for i in 1 2 3 4 5 6 7 8 9 10; do ps -eo args | grep -q "^/tmp/nexus-test-0129/bin/nexus serve" || break; sleep 1; done; mkdir -p /tmp/nexus-test-0129/bin' +scp -q "$BIN" "$HOST:/tmp/nexus-test-0129/bin/nexus" +scp -q "$HIER/remote.sh" "$HIER/config.toml.in" "$HOST:/tmp/nexus-test-0129/" +ssh "$HOST" 'chmod +x /tmp/nexus-test-0129/bin/nexus /tmp/nexus-test-0129/remote.sh; /tmp/nexus-test-0129/bin/nexus version; bash /tmp/nexus-test-0129/remote.sh prepare' +echo "Fertig. Starten: ssh $HOST 'bash /tmp/nexus-test-0129/remote.sh start'" diff --git a/scripts/srv04-engineui-test/remote.sh b/scripts/srv04-engineui-test/remote.sh new file mode 100755 index 0000000..fc52786 --- /dev/null +++ b/scripts/srv04-engineui-test/remote.sh @@ -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