-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add “Child process terminated via SIGTERM” logging to stderr
Problem: child processes (helm, deno) can be killed (usually OOM killed) without any logs Solution: Log “Child process terminated via SIGTERM” in that case to help identify the cause
- Loading branch information
Showing
7 changed files
with
48 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { toText } from "./text.ts" | ||
|
||
export async function waitForProcess( | ||
ps: Deno.Process, | ||
opts: { autoReject?: boolean } = {} | ||
) { | ||
const [status, output, error] = await Promise.all([ | ||
ps.status(), | ||
ps.output(), | ||
ps.stderrOutput(), | ||
]) | ||
ps.close() | ||
|
||
const stdout = toText(output) | ||
let stderr = toText(error) | ||
if (status.signal === Deno.Signal.SIGTERM) { | ||
stderr = `Child process terminated via SIGTERM\n${stderr}` | ||
} | ||
|
||
if (opts.autoReject) { | ||
if (!status.success) { | ||
console.log(stdout) | ||
return Promise.reject(stderr) | ||
} | ||
} | ||
|
||
return { status, stdout, stderr } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export function toText(bytes: Uint8Array): string { | ||
return new TextDecoder().decode(bytes) | ||
} |