Pass Node path to frontend services

This commit is contained in:
王鹏
2026-10-09 13:23:12 +08:00
parent e5e584eb73
commit c2d124cc09
3 changed files with 56 additions and 1 deletions

View File

@@ -662,6 +662,7 @@ def _restart_frontend(
stdin=subprocess.DEVNULL,
stdout=log_file,
stderr=subprocess.STDOUT,
env=_build_process_environment(command),
shell=False,
creationflags=_background_creation_flags(),
)
@@ -677,6 +678,9 @@ def _restart_frontend(
return_code = process.poll()
if return_code is not None:
on_output(f"{service_name}进程 PID {process.pid} 在端口就绪前退出,退出码: {return_code},日志: {log_path}")
log_tail = _read_log_tail(log_path)
if log_tail:
on_output(f"{service_name}日志末尾:\n{log_tail}")
return return_code or 1
time.sleep(0.2)
@@ -685,6 +689,18 @@ def _restart_frontend(
return 1
def _read_log_tail(log_path: Path, line_count: int = 30) -> str:
try:
raw_lines = log_path.read_bytes().splitlines()[-line_count:]
except OSError:
return ""
return "\n".join(
line
for line in (_decode_process_output(raw).rstrip() for raw in raw_lines)
if line
)
def _background_creation_flags() -> int:
if os.name != "nt":
return 0