Make local inference limits and workstation setup reproducible

This commit is contained in:
admin committed 2026-10-23 13:27:50 +02:00
1 parent 7006991843
commit 8544abd2d4
28 files changed
+1022 -21

No files matched your search

+55
View File
@@ -0,0 +1,55 @@
#!/usr/bin/env bash
# Explicit model selection. Stops current gateway requests; keeps both model files.
set -Eeuo pipefail
umask 077
config_dir="${XDG_CONFIG_HOME:-$HOME/.config}/hermes-stack-maintenance"
usage() {
printf 'Aufruf: %s [status|routine|large] (Modellwechsel beendet laufende Anfragen)\n' "$0"
}
case "${1:-}" in
''|status)
# shellcheck disable=SC1091
source "$config_dir/llama.env"
printf 'Aktives Modell: %s\nKonfiguration: %s/llama.env\n' "$LLAMA_MODEL" "$config_dir"
exit 0 ;;
-h|--help) usage; exit 0 ;;
routine|large) selected="$1" ;;
*) usage >&2; exit 2 ;;
esac
[[ $# -eq 1 ]] || exit 2
exec 9>"${XDG_RUNTIME_DIR:-/tmp}/hermes-stack-hermes-update.lock"
flock -n 9 || { printf 'Maintenance läuft.\n' >&2; exit 1; }
runner="$(dirname -- "$(readlink -f -- "${BASH_SOURCE[0]}")")/hermes-stack-llama-run"
candidate="$config_dir/llama-$selected.env"
HERMES_LLAMA_CONFIG="$candidate" "$runner" --check
backup="$(mktemp "$config_dir/llama.env.before-model-switch.XXXXXX")"
cp -p -- "$config_dir/llama.env" "$backup"
systemctl --user stop hermes-gateway.service
rollback() {
local rc=$?
trap - EXIT
if ((rc != 0)); then
install -m 0600 "$backup" "$config_dir/llama.env" || true
systemctl --user restart llama-qwen.service || true
systemctl --user start hermes-gateway.service || true
printf 'Modellwechsel fehlgeschlagen; vorherige Konfiguration zurückkopiert. Dienststatus prüfen.\n' >&2
fi
exit "$rc"
}
trap rollback EXIT
install -m 0600 "$candidate" "$config_dir/llama.env"
ready=0
if systemctl --user restart llama-qwen.service; then
for ((i=0; i<90; i++)); do
if curl -fsS --max-time 2 http://127.0.0.1:8080/health | jq -e '.status == "ok"' >/dev/null 2>&1; then
ready=1; break
fi
sleep 2
done
fi
if ((ready == 0)); then
exit 1
fi
systemctl --user start hermes-gateway.service
trap - EXIT
printf 'Modellprofil %s aktiv. Vorherige Konfiguration: %s\n' "$selected" "$backup"