fix(logs): bound stalled journal subprocesses

This commit is contained in:
zhang-guiping
2026-07-19 11:41:33 +08:00
committed by Mason Huang
parent e20d4cd450
commit dd16befe58
2 changed files with 15 additions and 1 deletions
+3 -1
View File
@@ -7,17 +7,19 @@ export { readSystemdServiceRuntime } from "../daemon/systemd.js";
type ExecFileTailResult = { stdout: string; stderr: string; code: number; truncated: boolean };
const DEFAULT_LOG_SUBPROCESS_TIMEOUT_MS = 10_000;
const STDERR_MAX_BYTES = 64 * 1024;
export async function execFileUtf8Tail(
command: string,
args: string[],
options: { env?: NodeJS.ProcessEnv; maxBytes: number },
options: { env?: NodeJS.ProcessEnv; maxBytes: number; timeoutMs?: number },
): Promise<ExecFileTailResult> {
try {
const result = await runCommandWithTimeout([command, ...args], {
baseEnv: options.env,
maxOutputBytes: { stdout: options.maxBytes, stderr: STDERR_MAX_BYTES },
timeoutMs: options.timeoutMs ?? DEFAULT_LOG_SUBPROCESS_TIMEOUT_MS,
});
return {
stdout: result.stdout,