mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 18:10:45 +00:00
fix(gateway): prefer linux child OOM victims
Raise eligible Linux child processes own oom_score_adj from a child-side /bin/sh exec shim so cgroup memory pressure prefers transient workers over the long-lived gateway. Cover supervisor children, PTY shells, MCP stdio servers, and OpenClaw-launched browser processes through the shared process runtime seam. Harden the wrapper for distroless images, shell startup env, per-child and process-level opt-outs, dash-compatible exec, and leading-dash command names. Document Linux verification and OOM behavior. Fixes #70404. Co-authored-by: Neerav Makwana <261249544+neeravmakwana@users.noreply.github.com>
This commit is contained in:
@@ -2,6 +2,7 @@ import { type ChildProcess, type ChildProcessWithoutNullStreams, spawn } from "n
|
||||
import fs from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { prepareOomScoreAdjustedSpawn } from "openclaw/plugin-sdk/process-runtime";
|
||||
import { normalizeOptionalString } from "openclaw/plugin-sdk/text-runtime";
|
||||
import type { SsrFPolicy } from "../infra/net/ssrf.js";
|
||||
import { ensurePortAvailable } from "../infra/ports.js";
|
||||
@@ -290,13 +291,16 @@ export async function launchOpenClawChrome(
|
||||
// environments (e.g. Docker), while keeping stderr piped for diagnostics.
|
||||
// Cast to ChildProcessWithoutNullStreams so callers can use .stderr safely;
|
||||
// the tuple overload resolution varies across @types/node versions.
|
||||
return spawn(exe.path, args, {
|
||||
stdio: ["ignore", "ignore", "pipe"],
|
||||
const preparedSpawn = prepareOomScoreAdjustedSpawn(exe.path, args, {
|
||||
env: {
|
||||
...process.env,
|
||||
// Reduce accidental sharing with the user's env.
|
||||
HOME: os.homedir(),
|
||||
},
|
||||
});
|
||||
return spawn(preparedSpawn.command, preparedSpawn.args, {
|
||||
stdio: ["ignore", "ignore", "pipe"],
|
||||
env: preparedSpawn.env,
|
||||
}) as unknown as ChildProcessWithoutNullStreams;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user