This repository has been archived on 2026-07-22. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
mission-control/config.py
T
Hitonabi acc754b93e fix: verstuemmelte MC_CMD_TEMPLATE abfangen (systemd-Quoting-Bug)
Eine unquotierte `Environment=MC_CMD_TEMPLATE=llama-server -m {model} ...`-Zeile
wird von systemd an Leerzeichen gesplittet -> nur "llama-server" kommt an. Dadurch
schrieb register/install nur "llama-server" ohne -m/-c in die config.yaml (coder/
vision/coder-fast blieben leer; nur scout war von provision.sh direkt gesetzt).

- config.py: fehlt {model} in MC_CMD_TEMPLATE -> sicherer Default
- mission-control.service: Environment-Wert gequotet + Warnhinweis

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-21 18:42:22 +02:00

58 lines
2.6 KiB
Python

"""
Zentrale Konfiguration fuer Mission Control.
Alles ueber Umgebungsvariablen ueberschreibbar. Wird von allen Modulen importiert,
damit es genau eine Quelle der Wahrheit fuer Pfade, URLs und Defaults gibt.
"""
import os
import sys
from pathlib import Path
from ruamel.yaml import YAML
# ---------------------------------------------------------------------------
# Env-Vars (siehe README fuer Bedeutung)
# ---------------------------------------------------------------------------
LLAMA_SWAP_URL = os.environ.get("MC_LLAMA_SWAP_URL", "http://127.0.0.1:8080").rstrip("/")
CONFIG_PATH = Path(os.environ.get("MC_CONFIG_PATH", "/etc/llama-swap/config.yaml"))
MODELS_DIR = Path(os.environ.get("MC_MODELS_DIR", "/srv/models"))
# Befehl, der zum Starten eines Modells in die config.yaml geschrieben wird.
# {model} = Pfad zur GGUF-Datei, {ctx} = Kontextlaenge, ${PORT} bleibt fuer llama-swap stehen.
# WICHTIG: an deinen Container-/llama-server-Aufruf anpassen (siehe README).
_DEFAULT_CMD_TEMPLATE = (
"llama-server -m {model} --host 127.0.0.1 --port ${PORT} "
"-c {ctx} -ngl 999 -fa 1 --no-mmap"
)
CMD_TEMPLATE = os.environ.get("MC_CMD_TEMPLATE", _DEFAULT_CMD_TEMPLATE)
# Schutz: Eine unquotierte systemd `Environment=MC_CMD_TEMPLATE=...`-Zeile wird an
# Leerzeichen gesplittet und kommt als blosses "llama-server" an. Fehlt der {model}-
# Platzhalter, ist die Vorlage unbrauchbar -> sicheren Default verwenden.
if "{model}" not in CMD_TEMPLATE:
CMD_TEMPLATE = _DEFAULT_CMD_TEMPLATE
# Befehl fuer "Container/Toolbox aktualisieren". Standard: kyuz0 refresh-Skript.
UPDATE_CMD = os.environ.get("MC_UPDATE_CMD", "")
DEFAULT_TTL = int(os.environ.get("MC_DEFAULT_TTL", "300"))
TOKEN = os.environ.get("MC_TOKEN", "") # leer = keine Auth (nur LAN!)
# Self-Update ("Mission Control aktualisieren"): Quelle = git-Repo, Prod = laufende Installation.
SOURCE_DIR = os.path.expanduser(os.environ.get("MC_SOURCE_DIR", "~/mission-control"))
PROD_DIR = str(Path(__file__).resolve().parent)
# Env fuer alle HuggingFace-Downloads: XET deaktivieren (mit aktivem XET haengt der
# Download reproduzierbar bei ~6 MB, siehe CLAUDE.md). Token wird je Job ergaenzt.
HF_DOWNLOAD_ENV = {"HF_HUB_DISABLE_XET": "1"}
def hf_bin() -> str:
"""Pfad zur `hf`-CLI fuer Modell-Downloads. Bevorzugt die im venv installierte
(neben dem laufenden Python), da der Dienst-PATH das venv/bin meist nicht
enthaelt. Faellt sonst auf ein global installiertes `hf` zurueck."""
cand = os.path.join(os.path.dirname(sys.executable), "hf")
return cand if os.path.exists(cand) else "hf"
# Gemeinsame YAML-Instanz (preserve_quotes haelt Kommentare/Quotes in config.yaml).
yaml = YAML()
yaml.preserve_quotes = True