修复:独立回收中断备份并限制 AI 日志增长
This commit is contained in:
@@ -991,7 +991,7 @@ def _model_settings(*, include_options=False):
|
||||
|
||||
def _config_fingerprint(model_base: str, model_key: str, model_name: str) -> str:
|
||||
paths = [TEMPLATES / "RULES.md", TEMPLATES / "agent" / "prompts" / "system.md",
|
||||
ROOT / "scripts" / "nao_quality_runtime.py", ROOT / "scripts" / "nao_quality_runtime_mcp.py",
|
||||
ROOT / "scripts" / "nao_quality_runtime.py", ROOT / "scripts" / "nao_quality_runtime_mcp.py", ROOT / "scripts" / "nao_log_stream.py",
|
||||
ROOT / "scripts" / "nao_quality_tools.py", ROOT / "scripts" / "nao_quality_mcp.py",
|
||||
ROOT / "scripts" / "nao_model_settings.py", ROOT / "scripts" / "nao_model_gate.py", ROOT / "scripts" / "nao_evidence_finalizer.py", ROOT / "scripts" / "nao_evidence_report.py", ROOT / "scripts" / "nao_weight_ranking.py",
|
||||
ROOT / "scripts" / "nao_metric_request.py", ROOT / "scripts" / "nao_analysis_coverage.py", ROOT / "scripts" / "nao_combined_ranking.py",
|
||||
@@ -1209,6 +1209,11 @@ def _process_matches(record: dict[str, Any], actor_root: Path) -> bool:
|
||||
if not start or start != record.get("lstart"):
|
||||
return False
|
||||
kind = record.get("kind")
|
||||
wrapper = str(Path(__file__).with_name("nao_log_stream.py"))
|
||||
if wrapper in command:
|
||||
name = "fastapi.log" if kind == "fastapi" else "server.log"
|
||||
if "--log " + str(actor_root / "logs" / name) not in command:
|
||||
return False
|
||||
if kind == "fastapi":
|
||||
return str(PYTHON) in command and str(FASTAPI_MAIN) in command
|
||||
if kind == "server":
|
||||
@@ -1668,21 +1673,23 @@ class RuntimeManager:
|
||||
path.touch(mode=0o600, exist_ok=True)
|
||||
path.chmod(0o600)
|
||||
processes: list[dict[str, Any]] = []
|
||||
log_path = logs / "server.log"
|
||||
fd = _open_server_log(log_path, actor_root)
|
||||
wrapper = str(Path(__file__).with_name("nao_log_stream.py"))
|
||||
for log_path in (logs / "fastapi.log", logs / "server.log"):
|
||||
os.close(_open_server_log(log_path, actor_root))
|
||||
try:
|
||||
with os.fdopen(fd, "ab") as log:
|
||||
fastapi = subprocess.Popen(
|
||||
[str(PYTHON), str(FASTAPI_MAIN)], cwd=project, env=env,
|
||||
stdin=subprocess.DEVNULL, stdout=log, stderr=log, start_new_session=True,
|
||||
)
|
||||
processes.append(_process_record(fastapi.pid, "fastapi", fastapi_port))
|
||||
server = subprocess.Popen(
|
||||
[str(NAO_SERVER), "serve", "--port", str(server_port), "--host", "127.0.0.1"],
|
||||
cwd=NAO_SERVER.parent, env=env, stdin=subprocess.DEVNULL,
|
||||
stdout=log, stderr=log, start_new_session=True,
|
||||
)
|
||||
processes.append(_process_record(server.pid, "server", server_port))
|
||||
fastapi = subprocess.Popen(
|
||||
[str(PYTHON), wrapper, "--log", str(logs / "fastapi.log"), "--", str(PYTHON), str(FASTAPI_MAIN)],
|
||||
cwd=project, env=env, stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL,
|
||||
stderr=subprocess.DEVNULL, start_new_session=True,
|
||||
)
|
||||
processes.append(_process_record(fastapi.pid, "fastapi", fastapi_port))
|
||||
server = subprocess.Popen(
|
||||
[str(PYTHON), wrapper, "--log", str(logs / "server.log"), "--", str(NAO_SERVER),
|
||||
"serve", "--port", str(server_port), "--host", "127.0.0.1"],
|
||||
cwd=NAO_SERVER.parent, env=env, stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL,
|
||||
stderr=subprocess.DEVNULL, start_new_session=True,
|
||||
)
|
||||
processes.append(_process_record(server.pid, "server", server_port))
|
||||
except Exception:
|
||||
for record in processes:
|
||||
if _process_matches(record, actor_root):
|
||||
|
||||
Reference in New Issue
Block a user