This commit is contained in:
2026-01-14 04:27:54 -08:00
parent cd60c86868
commit 187a230e98
8 changed files with 318 additions and 154 deletions

View File

@@ -3,6 +3,7 @@ from __future__ import annotations
import os
import sys
import subprocess
import atexit
from pathlib import Path
from typing import Optional
@@ -12,6 +13,11 @@ from SYS.logger import debug, log
_zt_server_proc: Optional[subprocess.Popen] = None
_zt_server_last_config: Optional[str] = None
# We no longer use atexit here because explicit lifecycle management
# is preferred in TUI/REPL, and background servers use a monitor thread
# to shut down when the parent dies.
# atexit.register(lambda: stop_zerotier_server())
def ensure_zerotier_server_running() -> None:
"""Check config and ensure the ZeroTier storage server is running if needed."""
global _zt_server_proc, _zt_server_last_config
@@ -92,7 +98,8 @@ def ensure_zerotier_server_running() -> None:
cmd = [python_exe, str(server_script),
"--storage-path", str(storage_path),
"--port", str(port)]
"--port", str(port),
"--monitor"]
if api_key:
cmd += ["--api-key", str(api_key)]