diff --git a/src/lib/inference/vllm.test.ts b/src/lib/inference/vllm.test.ts index a5bc873cca4..671d3680129 100644 --- a/src/lib/inference/vllm.test.ts +++ b/src/lib/inference/vllm.test.ts @@ -285,6 +285,7 @@ describe("vLLM profile detection", () => { const args = buildVllmRunArgs(runtime, ultra!, flags, {} as NodeJS.ProcessEnv); expect(args).toEqual([ "--pull=never", + "--init", "--restart", "unless-stopped", "--gpus", @@ -446,11 +447,18 @@ describe("vLLM image pull", () => { }); describe("vLLM run command", () => { + it("adds Docker init so restarts can reap the server process (#7219)", () => { + const profile = detectVllmProfile({ platform: "spark", type: "nvidia" }); + expect(profile).not.toBeNull(); + const args = buildVllmRunArgs(profile!, profile!.defaultModel, profile!.dockerRunFlags); + expect(args.slice(0, 4)).toEqual(["--pull=never", "--init", "--restart", "unless-stopped"]); + }); + it("adds --restart unless-stopped so the container survives a host reboot (#4886)", () => { const profile = detectVllmProfile({ platform: "spark", type: "nvidia" }); expect(profile).not.toBeNull(); const args = buildVllmRunArgs(profile!, profile!.defaultModel, profile!.dockerRunFlags); - expect(args.slice(0, 3)).toEqual(["--pull=never", "--restart", "unless-stopped"]); + expect(args).toEqual(expect.arrayContaining(["--restart", "unless-stopped"])); expect(args).toContain("--name"); expect(args[args.indexOf("--name") + 1]).toBe(profile!.containerName); expect(args).toEqual( @@ -997,7 +1005,13 @@ describe("installVllm model resolution", () => { { env?: Record }, ]; expect(args).toEqual( - expect.arrayContaining(["--pull=never", "--restart", "unless-stopped", profile.image]), + expect.arrayContaining([ + "--pull=never", + "--init", + "--restart", + "unless-stopped", + profile.image, + ]), ); expect(args).not.toContain("HF_TOKEN"); expect(args.join(" ")).not.toContain("hf_test"); diff --git a/src/lib/inference/vllm.ts b/src/lib/inference/vllm.ts index dc8c6089d57..c4d7f3d6c46 100644 --- a/src/lib/inference/vllm.ts +++ b/src/lib/inference/vllm.ts @@ -497,10 +497,11 @@ function validateDockerArgs(args: readonly string[], label: string): string[] { } // Build the `docker run` argv for the long-lived vLLM inference container. -// Exported for testing. `--restart unless-stopped` makes the container come -// back after a host reboot or Docker daemon restart (#4886); without a restart -// policy the container stays down after a reboot and `nemoclaw inference get` -// fails until a full `nemoclaw onboard --fresh --gpu` recreates it. +// Exported for testing. `--init` forwards signals and reaps child processes so +// Docker can stop and restart the long-lived server cleanly. `--restart +// unless-stopped` brings it back after a host reboot or Docker daemon restart +// (#4886); without a restart policy the container stays down after a reboot and +// `nemoclaw inference get` fails until onboarding recreates it. export function buildVllmRunArgs( profile: VllmProfile, model: VllmModelDef, @@ -513,6 +514,7 @@ export function buildVllmRunArgs( const safeRunFlags = validateDockerArgs(runFlags, "vLLM docker run flags"); return [ "--pull=never", + "--init", "--restart", "unless-stopped", ...safeRunFlags,