From 9794fb1061f64e1c4f05f8b60c44692104d1334e Mon Sep 17 00:00:00 2001 From: Alfred Date: Tue, 13 Jan 2026 17:19:39 +0800 Subject: [PATCH] Fix journalctl buffering causing incomplete log transmission --- src/tegrastats_api/model_monitor.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/tegrastats_api/model_monitor.py b/src/tegrastats_api/model_monitor.py index 7aff21b..eccc652 100644 --- a/src/tegrastats_api/model_monitor.py +++ b/src/tegrastats_api/model_monitor.py @@ -184,7 +184,9 @@ def _monitor_logs(self) -> None: # Get more historical lines to ensure we capture startup logs # LLM startup can be verbose, so we need more lines history_lines = 300 if self.model_type == "llm" else 200 - cmd = ["journalctl", "-u", self.service_name, "-f", "-n", str(history_lines)] + # Use stdbuf to force line-buffered output from journalctl + # This prevents log lines from getting stuck in journalctl's buffer + cmd = ["stdbuf", "-oL", "journalctl", "-u", self.service_name, "-f", "-n", str(history_lines)] self._process = subprocess.Popen( cmd, stdout=subprocess.PIPE,