613c570a3b
nix-hashes / compute-hash (blacksmith-4vcpu-ubuntu-2404, x86_64-linux) (push) Has been cancelled
nix-hashes / compute-hash (blacksmith-4vcpu-ubuntu-2404-arm, aarch64-linux) (push) Has been cancelled
nix-hashes / compute-hash (macos-15-intel, x86_64-darwin) (push) Has been cancelled
nix-hashes / compute-hash (macos-latest, aarch64-darwin) (push) Has been cancelled
nix-hashes / update-hashes (push) Has been cancelled
publish / version (push) Has been cancelled
publish / build-cli (push) Has been cancelled
publish / sign-cli-macos (push) Has been cancelled
publish / build-node-cli (map[host:blacksmith-4vcpu-ubuntu-2404 target:linux-x64]) (push) Has been cancelled
publish / build-node-cli (map[host:blacksmith-4vcpu-ubuntu-2404-arm target:linux-arm64]) (push) Has been cancelled
publish / build-node-cli (map[host:blacksmith-4vcpu-windows-2025 target:windows-arm64]) (push) Has been cancelled
publish / build-node-cli (map[host:blacksmith-4vcpu-windows-2025 target:windows-x64]) (push) Has been cancelled
publish / build-node-cli (map[host:macos-26 target:darwin-arm64]) (push) Has been cancelled
publish / sign-cli-windows (push) Has been cancelled
publish / build-electron (map[bun_install_flags:--os=darwin --cpu=arm64 host:macos-26 platform_flag:--mac --arm64 target:aarch64-apple-darwin]) (push) Has been cancelled
publish / build-electron (map[bun_install_flags:--os=darwin --cpu=x64 host:macos-26-intel platform_flag:--mac --x64 target:x86_64-apple-darwin]) (push) Has been cancelled
publish / build-electron (map[host:blacksmith-4vcpu-ubuntu-2404 platform_flag:--linux target:x86_64-unknown-linux-gnu]) (push) Has been cancelled
publish / build-electron (map[host:blacksmith-4vcpu-ubuntu-2404-arm platform_flag:--linux --arm64 target:aarch64-unknown-linux-gnu]) (push) Has been cancelled
publish / build-electron (map[host:blacksmith-4vcpu-windows-2025 platform_flag:--win target:x86_64-pc-windows-msvc]) (push) Has been cancelled
publish / build-electron (map[host:windows-2025 platform_flag:--win --arm64 target:aarch64-pc-windows-msvc]) (push) Has been cancelled
publish / publish (push) Has been cancelled
38 lines
1.4 KiB
TypeScript
38 lines
1.4 KiB
TypeScript
import { Global } from "@opencode-ai/util/global"
|
|
import { Effect, Queue } from "effect"
|
|
import path from "node:path"
|
|
|
|
export const listen = Effect.gen(function* () {
|
|
const global = yield* Global.Service
|
|
if (process.platform === "win32") return
|
|
const signals = yield* Queue.dropping<void>(1)
|
|
yield* Effect.acquireRelease(
|
|
Effect.sync(() => {
|
|
const handler = () => Queue.offerUnsafe(signals, undefined)
|
|
process.on("SIGUSR1", handler)
|
|
return handler
|
|
}),
|
|
(handler) => Effect.sync(() => process.off("SIGUSR1", handler)),
|
|
)
|
|
yield* Queue.take(signals).pipe(
|
|
Effect.andThen(
|
|
Effect.suspend(() => {
|
|
const file = path.join(
|
|
global.log,
|
|
`heap-${process.pid}-${new Date().toISOString().replace(/[:.]/g, "")}.heapsnapshot`,
|
|
)
|
|
return Effect.gen(function* () {
|
|
yield* Effect.logInfo("writing heap snapshot", { path: file })
|
|
const { writeHeapSnapshot } = yield* Effect.tryPromise(() => import("node:v8"))
|
|
yield* Effect.try(() => writeHeapSnapshot(file))
|
|
yield* Effect.logInfo("heap snapshot written", { path: file })
|
|
}).pipe(Effect.catchCause((cause) => Effect.logError("failed to write heap snapshot", { path: file, cause })))
|
|
}),
|
|
),
|
|
Effect.forever,
|
|
Effect.forkScoped({ startImmediately: true }),
|
|
)
|
|
})
|
|
|
|
export * as Heap from "./heap"
|