fix: Erkennung von bereits laufendem Server und dessen beendung. incl. Tests

This commit is contained in:
Rob committed 2026-10-07 19:49:39 +02:00
1 parent 1519b96c7b
commit 971459c9bf
8 files changed
+420 -169

No files matched your search

+13
View File
@@ -12,12 +12,17 @@ Dieses Skript:
"""
import os
import subprocess
import sys
import threading
import time
import webbrowser
from pathlib import Path
if not getattr(sys, "frozen", False):
sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "0_application"))
from server_lifecycle import stop_existing_server
def _get_base_dir() -> Path:
"""Verzeichnis der .exe (bzw. des Skripts im Entwicklungsmodus)."""
@@ -44,6 +49,14 @@ def _ensure_dirs(base_dir: Path) -> None:
def main() -> None:
# Only open the browser/start Streamlit once the previous server has stopped.
try:
if not stop_existing_server():
print("[INFO] Die bisherige Version bleibt geöffnet. Keine neue Instanz gestartet.")
return
except (RuntimeError, OSError, subprocess.SubprocessError) as exc:
print(f"[FEHLER] Server-Neustart fehlgeschlagen: {exc}", file=sys.stderr)
raise SystemExit(1)
base_dir = _get_base_dir()
# Im gebundelten Modus: sys._MEIPASS enthält src/ und app.py