@camstack/system 1.2.311 → 1.2.313
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/addon-runner.js +6 -8
- package/dist/addon-runner.mjs +6 -8
- package/dist/builtins/native-metrics/native-metrics.addon.js +9 -101
- package/dist/builtins/native-metrics/native-metrics.addon.mjs +3 -91
- package/dist/{child-cap-dispatch-BCJjUtXV.mjs → child-cap-dispatch-CHTiHbsv.mjs} +294 -10
- package/dist/{child-cap-dispatch-Be8e2cBP.js → child-cap-dispatch-Dyn_7ezH.js} +347 -9
- package/dist/index.js +87 -17
- package/dist/index.mjs +88 -19
- package/dist/kernel/index.d.ts +1 -0
- package/dist/kernel/moleculer/process-service.d.ts +9 -0
- package/dist/kernel/moleculer/runner-process-group.d.ts +92 -0
- package/dist/proc-stat-CbC55Kqi.mjs +92 -0
- package/dist/proc-stat-DL-WUOhl.js +127 -0
- package/dist/{resource-monitor-Vp0bPV3U.mjs → resource-monitor-B1v6E07R.mjs} +1 -1
- package/dist/{resource-monitor-LVE1BoLs.js → resource-monitor-DzNn_IZK.js} +5 -5
- package/package.json +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { a as parseProcStat, i as nodeProcReader } from "./proc-stat-CbC55Kqi.mjs";
|
|
1
2
|
import "./hub-cap-forward-BdT320dq.mjs";
|
|
2
3
|
import * as crypto$1 from "node:crypto";
|
|
3
4
|
import { randomBytes, randomUUID } from "node:crypto";
|
|
@@ -3207,7 +3208,7 @@ function createAddonPeerBytesFacility(args) {
|
|
|
3207
3208
|
* Failures THROW with an actionable message — a caller must never proceed as
|
|
3208
3209
|
* if dependencies were installed when they were not.
|
|
3209
3210
|
*/
|
|
3210
|
-
var execFileAsync$
|
|
3211
|
+
var execFileAsync$3 = promisify(execFile);
|
|
3211
3212
|
var DEFAULT_REGISTRY = "https://registry.npmjs.org";
|
|
3212
3213
|
/** Where the bootstrap lands inside `cacheDir` (npm tgz carries a `package/` prefix). */
|
|
3213
3214
|
function bootstrappedCliPath(cacheDir) {
|
|
@@ -3215,7 +3216,7 @@ function bootstrappedCliPath(cacheDir) {
|
|
|
3215
3216
|
}
|
|
3216
3217
|
async function defaultProbeSystemNpm() {
|
|
3217
3218
|
try {
|
|
3218
|
-
await execFileAsync$
|
|
3219
|
+
await execFileAsync$3("npm", ["--version"], { timeout: 15e3 });
|
|
3219
3220
|
return true;
|
|
3220
3221
|
} catch {
|
|
3221
3222
|
return false;
|
|
@@ -3233,7 +3234,7 @@ async function defaultDownloadTarball(url, destTgz) {
|
|
|
3233
3234
|
await fs.promises.writeFile(destTgz, bytes);
|
|
3234
3235
|
}
|
|
3235
3236
|
async function defaultExtractTarball(tgzPath, destDir) {
|
|
3236
|
-
await execFileAsync$
|
|
3237
|
+
await execFileAsync$3("tar", [
|
|
3237
3238
|
"-xzf",
|
|
3238
3239
|
tgzPath,
|
|
3239
3240
|
"-C",
|
|
@@ -3304,7 +3305,7 @@ async function runNpm(args, options) {
|
|
|
3304
3305
|
registry: options.registry,
|
|
3305
3306
|
logger: options.logger
|
|
3306
3307
|
});
|
|
3307
|
-
return execFileAsync$
|
|
3308
|
+
return execFileAsync$3(invocation.command, [...invocation.argsPrefix, ...args], {
|
|
3308
3309
|
...options.cwd !== void 0 ? { cwd: options.cwd } : {},
|
|
3309
3310
|
timeout: options.timeout ?? 3e5,
|
|
3310
3311
|
env: buildNpmChildEnv(options.env ?? process.env, process.execPath)
|
|
@@ -3385,7 +3386,7 @@ function resolveAddonClass(mod) {
|
|
|
3385
3386
|
}
|
|
3386
3387
|
//#endregion
|
|
3387
3388
|
//#region src/kernel/deps/manifest-native-deps.ts
|
|
3388
|
-
var execFileAsync$
|
|
3389
|
+
var execFileAsync$2 = promisify(execFile);
|
|
3389
3390
|
/**
|
|
3390
3391
|
* Fallback bootstrap-cache location when the caller doesn't thread one
|
|
3391
3392
|
* through (the forked addon-runner's spawn-time install). tmpdir survives the
|
|
@@ -3694,7 +3695,7 @@ async function rebuildNativeDeps(addonDir, packageNames, logger, npmCacheDir, re
|
|
|
3694
3695
|
return;
|
|
3695
3696
|
}
|
|
3696
3697
|
logger.warn("@electron/rebuild not available — falling back to npx", { meta: { addonDir } });
|
|
3697
|
-
await execFileAsync$
|
|
3698
|
+
await execFileAsync$2("npx", [
|
|
3698
3699
|
"--yes",
|
|
3699
3700
|
"electron-rebuild",
|
|
3700
3701
|
"-m",
|
|
@@ -12116,7 +12117,7 @@ function requestPrivilegedInstall(req, socketPath = pkgdSocketPath(), timeoutMs
|
|
|
12116
12117
|
* the failure it precedes ("smbclient: ENOENT") arrives minutes later in a
|
|
12117
12118
|
* different addon's logs.
|
|
12118
12119
|
*/
|
|
12119
|
-
var execFileAsync = promisify(execFile);
|
|
12120
|
+
var execFileAsync$1 = promisify(execFile);
|
|
12120
12121
|
/** How long a single package-manager invocation may take. */
|
|
12121
12122
|
var INSTALL_TIMEOUT_MS = 300 * 1e3;
|
|
12122
12123
|
/** How long the `command -v <binary>` presence probe may take. */
|
|
@@ -12278,7 +12279,7 @@ function planFor(manager, packageName) {
|
|
|
12278
12279
|
}
|
|
12279
12280
|
async function defaultHasBinary(binary) {
|
|
12280
12281
|
try {
|
|
12281
|
-
await execFileAsync("command", ["-v", binary], {
|
|
12282
|
+
await execFileAsync$1("command", ["-v", binary], {
|
|
12282
12283
|
timeout: PROBE_TIMEOUT_MS,
|
|
12283
12284
|
shell: process.platform === "win32" ? false : "/bin/sh"
|
|
12284
12285
|
});
|
|
@@ -12298,7 +12299,290 @@ async function defaultDetectManager() {
|
|
|
12298
12299
|
return null;
|
|
12299
12300
|
}
|
|
12300
12301
|
async function defaultRun(command, args) {
|
|
12301
|
-
await execFileAsync(command, [...args], { timeout: INSTALL_TIMEOUT_MS });
|
|
12302
|
+
await execFileAsync$1(command, [...args], { timeout: INSTALL_TIMEOUT_MS });
|
|
12303
|
+
}
|
|
12304
|
+
//#endregion
|
|
12305
|
+
//#region src/kernel/moleculer/runner-process-group.ts
|
|
12306
|
+
/**
|
|
12307
|
+
* A runner OWNS a process group, and the kernel reaps it on every runner exit (D668).
|
|
12308
|
+
*
|
|
12309
|
+
* ## Why
|
|
12310
|
+
*
|
|
12311
|
+
* An addon-runner spawns long-lived children: recorder ffmpeg writers, stream-broker
|
|
12312
|
+
* ffmpeg, llama-server, tailscaled, cloudflared, HAP ffmpeg. Their only kill was the
|
|
12313
|
+
* addon's own graceful `stop()`, which a runner that dies of SIGABRT (V8 OOM), SIGKILL
|
|
12314
|
+
* or a native crash never runs. ffmpeg ignores SIGPIPE and does not quit on stdin EOF,
|
|
12315
|
+
* so a dead reader does not stop it either. On 2026-09-28 at 10:21 CEST the hub's
|
|
12316
|
+
* recorder runner aborted; 28 ffmpeg writers survived as orphans and kept writing into
|
|
12317
|
+
* the SAME staging directories the respawned runner's 28 new writers used — 13 minutes
|
|
12318
|
+
* of dual writers on every camera, until they were killed by hand.
|
|
12319
|
+
*
|
|
12320
|
+
* Runners were spawned `detached: false`, i.e. inside hub-main's own group, so there
|
|
12321
|
+
* was no handle meaning "this runner and everything under it". Now every runner is
|
|
12322
|
+
* spawned `detached: true` on POSIX, which makes it a SESSION and group leader
|
|
12323
|
+
* (`setsid`): pgid === runner pid, and every descendant that does not itself call
|
|
12324
|
+
* `setsid`/`setpgid` inherits that group. A process group outlives its leader, so
|
|
12325
|
+
* `kill(-pgid)` still reaches the orphans after the runner is gone — which is exactly
|
|
12326
|
+
* the moment it matters.
|
|
12327
|
+
*
|
|
12328
|
+
* ## What `detached` does NOT change
|
|
12329
|
+
*
|
|
12330
|
+
* - The child stays REF'd: nothing calls `unref()`, so the parent still waits on it,
|
|
12331
|
+
* still gets its `exit`, still reads its stdout/stderr pipes.
|
|
12332
|
+
* - `process.ppid` is unchanged, so the runner can detect a lost parent before or
|
|
12333
|
+
* after READY and hard-stop its own group.
|
|
12334
|
+
* - UDS/stdio wiring is fd-based and independent of the session.
|
|
12335
|
+
*
|
|
12336
|
+
* What it DOES change: the runner is no longer in hub-main's group, so a signal sent to
|
|
12337
|
+
* hub-main's group (`kill -- -<pid>` in `server/backend/src/main.ts`, a terminal Ctrl+C)
|
|
12338
|
+
* no longer reaches runners by itself. `signalAllRunnerGroups` is the replacement, and
|
|
12339
|
+
* the process `exit` backstop below hard-stops any groups a hub/agent still owns.
|
|
12340
|
+
*
|
|
12341
|
+
* ## Out of scope, deliberately
|
|
12342
|
+
*
|
|
12343
|
+
* - Windows has no process groups in this sense; nothing here runs on `win32` and the
|
|
12344
|
+
* runner is spawned exactly as before.
|
|
12345
|
+
* - A descendant that calls `setsid`/`setpgid` itself (or is spawned `detached: true`
|
|
12346
|
+
* by an addon) leaves the group and is NOT reaped. No shipped addon does; one that
|
|
12347
|
+
* needs to must own its child's lifetime some other way.
|
|
12348
|
+
* - The kernel knows the runner id, not which device a child served. Per-device
|
|
12349
|
+
* attribution is the addon's (the recorder's own foreign-writer reap, D667).
|
|
12350
|
+
*/
|
|
12351
|
+
var execFileAsync = promisify(execFile);
|
|
12352
|
+
/** SIGTERM → SIGKILL grace for a runner's group, in ms. ffmpeg finalises a segment well inside it. */
|
|
12353
|
+
var RUNNER_GROUP_REAP_GRACE_MS = 2e3;
|
|
12354
|
+
/** How often the group is probed for emptiness during the grace. */
|
|
12355
|
+
var GROUP_PROBE_INTERVAL_MS = 100;
|
|
12356
|
+
/** Whether a runner is spawned as a process-group leader on this platform. */
|
|
12357
|
+
function runnerOwnsProcessGroup(platform = process.platform) {
|
|
12358
|
+
return platform !== "win32";
|
|
12359
|
+
}
|
|
12360
|
+
function errnoOf(err) {
|
|
12361
|
+
if (typeof err !== "object" || err === null) return void 0;
|
|
12362
|
+
const code = Reflect.get(err, "code");
|
|
12363
|
+
return typeof code === "string" ? code : void 0;
|
|
12364
|
+
}
|
|
12365
|
+
function signalGroup(ops, pgid, signal) {
|
|
12366
|
+
try {
|
|
12367
|
+
ops.kill(-pgid, signal);
|
|
12368
|
+
return "delivered";
|
|
12369
|
+
} catch (err) {
|
|
12370
|
+
if (errnoOf(err) === "ESRCH") return "empty";
|
|
12371
|
+
return { error: `${errnoOf(err) ?? "unknown"}: ${err instanceof Error ? err.message : String(err)}` };
|
|
12372
|
+
}
|
|
12373
|
+
}
|
|
12374
|
+
function signalPid(ops, pid) {
|
|
12375
|
+
try {
|
|
12376
|
+
ops.kill(pid, 0);
|
|
12377
|
+
return "delivered";
|
|
12378
|
+
} catch (err) {
|
|
12379
|
+
return errnoOf(err) === "ESRCH" ? "empty" : { error: errnoOf(err) ?? "unknown" };
|
|
12380
|
+
}
|
|
12381
|
+
}
|
|
12382
|
+
/**
|
|
12383
|
+
* A pgid this module may address. `kill(-1)` signals every process the caller may
|
|
12384
|
+
* signal and `kill(-0)` is the caller's OWN group — both are catastrophes, not reaps.
|
|
12385
|
+
*/
|
|
12386
|
+
function isAddressableGroup(pgid) {
|
|
12387
|
+
return Number.isInteger(pgid) && pgid > 1 && pgid !== process.pid;
|
|
12388
|
+
}
|
|
12389
|
+
/**
|
|
12390
|
+
* SIGTERM the whole group, wait up to `graceMs` for it to empty, SIGKILL what is left.
|
|
12391
|
+
*
|
|
12392
|
+
* pid reuse: POSIX never hands out a pid while a process group with that id exists, so
|
|
12393
|
+
* the SIGTERM always lands on our group. The SIGKILL is sent only when the group is
|
|
12394
|
+
* still populated at the end of the grace, which is the same group; the residual window
|
|
12395
|
+
* (group empties, the pid wraps around AND is reused as a new group leader, all inside
|
|
12396
|
+
* the grace) is not reachable in practice.
|
|
12397
|
+
*/
|
|
12398
|
+
async function reapProcessGroup(pgid, ops) {
|
|
12399
|
+
if (!isAddressableGroup(pgid)) return {
|
|
12400
|
+
pgid,
|
|
12401
|
+
membersAtExit: null,
|
|
12402
|
+
killed: null,
|
|
12403
|
+
alreadyEmpty: true,
|
|
12404
|
+
error: `refused pgid ${pgid}`
|
|
12405
|
+
};
|
|
12406
|
+
const membersAtExit = await ops.listMembers(pgid);
|
|
12407
|
+
const term = signalGroup(ops, pgid, "SIGTERM");
|
|
12408
|
+
if (term === "empty") return {
|
|
12409
|
+
pgid,
|
|
12410
|
+
membersAtExit,
|
|
12411
|
+
killed: [],
|
|
12412
|
+
alreadyEmpty: true,
|
|
12413
|
+
error: null
|
|
12414
|
+
};
|
|
12415
|
+
if (typeof term === "object") return {
|
|
12416
|
+
pgid,
|
|
12417
|
+
membersAtExit,
|
|
12418
|
+
killed: null,
|
|
12419
|
+
alreadyEmpty: false,
|
|
12420
|
+
error: term.error
|
|
12421
|
+
};
|
|
12422
|
+
for (let waited = 0; waited < ops.graceMs; waited += GROUP_PROBE_INTERVAL_MS) {
|
|
12423
|
+
await ops.sleep(Math.min(GROUP_PROBE_INTERVAL_MS, ops.graceMs - waited));
|
|
12424
|
+
if (signalGroup(ops, pgid, 0) === "empty") return {
|
|
12425
|
+
pgid,
|
|
12426
|
+
membersAtExit,
|
|
12427
|
+
killed: [],
|
|
12428
|
+
alreadyEmpty: false,
|
|
12429
|
+
error: null
|
|
12430
|
+
};
|
|
12431
|
+
}
|
|
12432
|
+
const survivors = membersAtExit === null ? null : membersAtExit.filter((m) => signalPid(ops, m.pid) === "delivered");
|
|
12433
|
+
const kill = signalGroup(ops, pgid, "SIGKILL");
|
|
12434
|
+
return {
|
|
12435
|
+
pgid,
|
|
12436
|
+
membersAtExit,
|
|
12437
|
+
killed: kill === "empty" ? [] : survivors,
|
|
12438
|
+
alreadyEmpty: false,
|
|
12439
|
+
error: typeof kill === "object" ? kill.error : null
|
|
12440
|
+
};
|
|
12441
|
+
}
|
|
12442
|
+
/** `ffmpeg×28 llama-server×1` — what a reap line says it removed. */
|
|
12443
|
+
function summarizeMembers(members) {
|
|
12444
|
+
const counts = /* @__PURE__ */ new Map();
|
|
12445
|
+
for (const m of members) counts.set(m.command, (counts.get(m.command) ?? 0) + 1);
|
|
12446
|
+
return [...counts.entries()].map(([command, n]) => `${command}×${n}`).join(" ");
|
|
12447
|
+
}
|
|
12448
|
+
async function listMembersFromProc(pgid, reader) {
|
|
12449
|
+
const pids = await reader.listPids();
|
|
12450
|
+
return (await Promise.all(pids.map(async (pid) => {
|
|
12451
|
+
try {
|
|
12452
|
+
return parseProcStat(await reader.readStat(pid));
|
|
12453
|
+
} catch {
|
|
12454
|
+
return null;
|
|
12455
|
+
}
|
|
12456
|
+
}))).flatMap((row) => row !== null && row.pgid === pgid && row.state !== "Z" ? [{
|
|
12457
|
+
pid: row.pid,
|
|
12458
|
+
command: row.comm
|
|
12459
|
+
}] : []);
|
|
12460
|
+
}
|
|
12461
|
+
var PS_GROUP_ROW_RE = /^(\d+)\s+(\d+)\s+(\S+)\s+(.+)$/;
|
|
12462
|
+
/** Parse `ps -A -o pid=,pgid=,stat=,comm=` for one group, zombies excluded. */
|
|
12463
|
+
function parsePsGroupMembers(stdout, pgid) {
|
|
12464
|
+
const members = [];
|
|
12465
|
+
for (const line of stdout.split("\n")) {
|
|
12466
|
+
const match = line.trim().match(PS_GROUP_ROW_RE);
|
|
12467
|
+
if (!match) continue;
|
|
12468
|
+
const [, pidS, pgidS, stat = "", comm = ""] = match;
|
|
12469
|
+
if (Number(pgidS) !== pgid || stat.startsWith("Z")) continue;
|
|
12470
|
+
const command = comm.trim();
|
|
12471
|
+
members.push({
|
|
12472
|
+
pid: Number(pidS),
|
|
12473
|
+
command: command.slice(command.lastIndexOf("/") + 1)
|
|
12474
|
+
});
|
|
12475
|
+
}
|
|
12476
|
+
return members;
|
|
12477
|
+
}
|
|
12478
|
+
async function listMembersFromPs(pgid) {
|
|
12479
|
+
const { stdout } = await execFileAsync("ps", [
|
|
12480
|
+
"-A",
|
|
12481
|
+
"-o",
|
|
12482
|
+
"pid=,pgid=,stat=,comm="
|
|
12483
|
+
], {
|
|
12484
|
+
timeout: 3e3,
|
|
12485
|
+
maxBuffer: 8 * 1024 * 1024
|
|
12486
|
+
});
|
|
12487
|
+
return parsePsGroupMembers(stdout, pgid);
|
|
12488
|
+
}
|
|
12489
|
+
/** Live members of `pgid`: `/proc` on Linux, `ps` elsewhere; `null` when neither answers. */
|
|
12490
|
+
async function listProcessGroupMembers(pgid, platform = process.platform) {
|
|
12491
|
+
try {
|
|
12492
|
+
return platform === "linux" ? await listMembersFromProc(pgid, nodeProcReader) : await listMembersFromPs(pgid);
|
|
12493
|
+
} catch {
|
|
12494
|
+
return null;
|
|
12495
|
+
}
|
|
12496
|
+
}
|
|
12497
|
+
var defaultProcessGroupOps = {
|
|
12498
|
+
kill: (pid, signal) => {
|
|
12499
|
+
process.kill(pid, signal);
|
|
12500
|
+
},
|
|
12501
|
+
listMembers: (pgid) => listProcessGroupMembers(pgid),
|
|
12502
|
+
sleep: (ms) => new Promise((resolve) => setTimeout(resolve, ms)),
|
|
12503
|
+
graceMs: RUNNER_GROUP_REAP_GRACE_MS
|
|
12504
|
+
};
|
|
12505
|
+
/**
|
|
12506
|
+
* Every runner group this process leads and has not finished reaping. Process-wide on
|
|
12507
|
+
* purpose: `process.on('exit')` and hub-main's signal handler must reach the groups of
|
|
12508
|
+
* every `$process` service in the process, and neither holds a service reference.
|
|
12509
|
+
*/
|
|
12510
|
+
var ownedGroups = /* @__PURE__ */ new Map();
|
|
12511
|
+
var exitBackstopInstalled = false;
|
|
12512
|
+
function installExitBackstop() {
|
|
12513
|
+
if (exitBackstopInstalled) return;
|
|
12514
|
+
exitBackstopInstalled = true;
|
|
12515
|
+
process.on("exit", () => {
|
|
12516
|
+
for (const [pgid, group] of ownedGroups) try {
|
|
12517
|
+
group.kill(-pgid, "SIGKILL");
|
|
12518
|
+
} catch {}
|
|
12519
|
+
});
|
|
12520
|
+
}
|
|
12521
|
+
function registerRunnerGroup(pgid, group) {
|
|
12522
|
+
if (!isAddressableGroup(pgid)) return;
|
|
12523
|
+
ownedGroups.set(pgid, group);
|
|
12524
|
+
installExitBackstop();
|
|
12525
|
+
}
|
|
12526
|
+
function releaseRunnerGroup(pgid) {
|
|
12527
|
+
ownedGroups.delete(pgid);
|
|
12528
|
+
}
|
|
12529
|
+
/**
|
|
12530
|
+
* Signal every runner group this process owns, synchronously. Hub-main's SIGTERM/SIGINT
|
|
12531
|
+
* handler calls it: before D668 the runners were in hub-main's own group and its
|
|
12532
|
+
* `kill -- -<pid>` reached them and their children; now each is its own group.
|
|
12533
|
+
* Returns how many groups were signalled.
|
|
12534
|
+
*/
|
|
12535
|
+
function signalAllRunnerGroups(signal) {
|
|
12536
|
+
let signalled = 0;
|
|
12537
|
+
for (const [pgid, group] of ownedGroups) try {
|
|
12538
|
+
group.kill(-pgid, signal);
|
|
12539
|
+
signalled += 1;
|
|
12540
|
+
} catch {}
|
|
12541
|
+
return signalled;
|
|
12542
|
+
}
|
|
12543
|
+
/**
|
|
12544
|
+
* Arm the runner's parent-death watchdog before addon code starts loading.
|
|
12545
|
+
*
|
|
12546
|
+
* A parent can die while an addon module or `initialize()` is still pending, so
|
|
12547
|
+
* installing this only after READY leaves exactly the boot window where a detached
|
|
12548
|
+
* runner can become an orphan. Any PPID change means the direct parent died and the
|
|
12549
|
+
* kernel reparented us; checking for a change also covers a non-PID-1 subreaper.
|
|
12550
|
+
*/
|
|
12551
|
+
function startRunnerParentDeathWatchdog(onParentDeath, options = {}) {
|
|
12552
|
+
const initialPpid = options.initialPpid ?? process.ppid;
|
|
12553
|
+
if (!Number.isInteger(initialPpid) || initialPpid <= 1) return null;
|
|
12554
|
+
const readPpid = options.readPpid ?? (() => process.ppid);
|
|
12555
|
+
const intervalMs = options.intervalMs ?? 5e3;
|
|
12556
|
+
let fired = false;
|
|
12557
|
+
const timer = setInterval(() => {
|
|
12558
|
+
if (fired || readPpid() === initialPpid) return;
|
|
12559
|
+
fired = true;
|
|
12560
|
+
clearInterval(timer);
|
|
12561
|
+
onParentDeath();
|
|
12562
|
+
}, intervalMs);
|
|
12563
|
+
return timer;
|
|
12564
|
+
}
|
|
12565
|
+
/**
|
|
12566
|
+
* Last resort for a detached runner whose direct parent disappeared without an
|
|
12567
|
+
* `exit` hook (SIGKILL, native crash). The runner's own pid is also its pgid, so
|
|
12568
|
+
* one SIGKILL removes the runner and every descendant in that group atomically.
|
|
12569
|
+
*
|
|
12570
|
+
* Calling `kill(-process.pid, ...)` from an ordinary, non-group-leading process
|
|
12571
|
+
* returns ESRCH: while this pid exists, no unrelated process group can have the
|
|
12572
|
+
* same id. That makes the failed call a safe compatibility fallback for an older
|
|
12573
|
+
* parent that did not spawn the runner detached.
|
|
12574
|
+
*/
|
|
12575
|
+
function killOwnRunnerGroupAfterParentLoss(platform = process.platform, kill = (target, signal) => {
|
|
12576
|
+
process.kill(target, signal);
|
|
12577
|
+
}) {
|
|
12578
|
+
const pid = process.pid;
|
|
12579
|
+
if (!runnerOwnsProcessGroup(platform) || !Number.isInteger(pid) || pid <= 1) return false;
|
|
12580
|
+
try {
|
|
12581
|
+
kill(-pid, "SIGKILL");
|
|
12582
|
+
return true;
|
|
12583
|
+
} catch {
|
|
12584
|
+
return false;
|
|
12585
|
+
}
|
|
12302
12586
|
}
|
|
12303
12587
|
//#endregion
|
|
12304
12588
|
//#region src/kernel/moleculer/child-cap-dispatch.ts
|
|
@@ -12351,4 +12635,4 @@ function createChildCapDispatch(deps) {
|
|
|
12351
12635
|
};
|
|
12352
12636
|
}
|
|
12353
12637
|
//#endregion
|
|
12354
|
-
export {
|
|
12638
|
+
export { CapUsageRegistry as $, capActionLabel as $n, buildHeapSample as $t, resolveHwAccel as A, createOutboundQueueGate as An, CapabilityUnavailableError as At, udsChildLogToWorkerEntry as B, diffSocketPlane as Bn, HEAP_RECLAIM_MIN_INTERVAL_MS as Bt, getBrokerEventBus as C, formatHeapSpaces as Cn, capBareAction as Ct, subscribePassthrough as D, OUTBOUND_QUEUE_COOLDOWN_MS as Dn, serializeTypedArrays as Dt, setNodeEventInterest as E, selectReportedSpaces as En, deserializeTypedArrays as Et, ipcParentLink as F, EMPTY_SOCKET_PLANE_BASELINE as Fn, resolveNpmInvocation as Ft, CapRouteResolver as G, recordSocketFrame as Gn, HUB_MAIN_HEAP_WATCH_LABEL as Gt, createUdsLoggerWithControl as H, readSocketQueues as Hn, HEAP_RECLAIM_TRIGGER_MB as Ht, localProviderLink as I, SOCKET_PLANE_TOP_N as In, runNpm as It, classifyCapRoute as J, socketDirectionMessages as Jn, RSS_BUDGET_REANNOUNCE_MIN_MS as Jt, callWithServiceDiscovery as K, sampleSocketDirection as Kn, HUB_MAIN_RSS_BUDGET_MB as Kt, createParentUnownedCallHandler as L, SOCKET_QUEUE_TOP_N as Ln, createAddonPeerBytesFacility as Lt, brokerTransportLink as M, MESH_QUEUE_TOP_N as Mn, installManifestNativeDeps as Mt, buildLinkChain as N, createMeshQueueReader as Nn, resolveAddonClass as Nt, AddonDepsManager as O, OUTBOUND_QUEUE_SUSTAIN_MS as On, DeviceRegistry as Ot, deviceCapResolverLink as P, formatMeshQueue as Pn, buildNpmChildEnv as Pt, readMoleculerFanoutMode as Q, MAX_CAP_ACTIONS_PER_PEER as Qn, ZERO_LOOP_DELAY as Qt, createUdsEventBridge as R, createSocketPlaneMeter as Rn, hostNodeIdOf as Rt, clusterEventTopic as S, emitHeapDiagnosticReport as Sn, capActionSuffix as St, registerEventBusService as T, readHeapSpaces as Tn, parseCapAction as Tt, AGENT_CAP_FWD_ACTION as U, EMPTY_SOCKET_DIRECTION as Un, HEAP_WATCH_INTERVAL_MS as Ut, createUdsLogger as V, formatSocketPlane as Vn, HEAP_RECLAIM_STEADY_STATE_INTERVAL_MS as Vt, AGENT_CAP_FWD_SERVICE as W, createSocketDirectionCounters as Wn, HEAP_WATCH_WARN_RATIO as Wt, LocalChildRegistry as X, CAP_ACTION_UNLABELLED as Xn, RUNNER_HEAP_WATCH_INTERVAL_MS as Xt, LocalChildClient as Y, CAP_ACTION_OVERFLOW_LABEL as Yn, RSS_BUDGET_RELEASE_RATIO as Yt, UDS_NO_ROUTE_PREFIX as Z, EMPTY_CAP_ACTION_READING as Zn, RUNNER_RSS_BUDGET_ENV as Zt, getWorkerDeviceRegistry as _, createInspectorArrayBufferCensus as _n, setWorkerNativeCapsChangeListener as _t, reapProcessGroup as a, nextRssBudgetState as an, diffEventPlane as ar, UdsLocalTransportServer as at, setHubConnected as b, DECISIVE_HEAP_SPACES as bn, NATIVE_PROVIDER_SERVICE_INFIX as bt, runnerOwnsProcessGroup as c, shouldReclaim as cn, localEndpointPath as ct, summarizeMembers as d, strandedMb as dn, buildNativeCapProxy as dt, createDeferredHeapWatchSink as en, createCapActionCensus as er, PARENT_ROUTED_PROVIDER_ADDON_ID as et, installManifestSystemDeps as f, ARRAY_BUFFER_CENSUS_COOLDOWN_MS as fn, buildUdsNativeCapProxy as ft, createUdsAddonContext as g, createArrayBufferCensusGate as gn, mountNativeCapService as gt, createAddonContext as h, ARRAY_BUFFER_RELEASE_MIN_DROP_RATIO as hn, getWorkerNativeCapSnapshot as ht, killOwnRunnerGroupAfterParentLoss as i, hubMainRssBudget as in, createEventPlaneReader as ir, UdsLocalTransportClient as it, brokerCallForCap as j, formatOutboundQueueVerdict as jn, copyBundledNativeModules as jt, createKernelHwAccel as k, OUTBOUND_QUEUE_THRESHOLD_BYTES as kn, CapabilityHandle as kt, signalAllRunnerGroups as l, startHeapWatch as ln, FrameDecoder as lt, adaptBrokerToCluster as m, ARRAY_BUFFER_CENSUS_THRESHOLD_MB as mn, getWorkerNativeCapProvider as mt, createChildCapDispatch as n, createV8Reclaimer as nn, EVENT_PLANE_TOP_N as nr, getCapUsageRegistry as nt, registerRunnerGroup as o, parseRssBudgetMb as on, formatEventPlane as or, SocketChannel as ot, installManifestPythonDeps as p, ARRAY_BUFFER_CENSUS_SUSTAIN_MS as pn, createBrokerDeviceManagerApi as pt, CapRouteError as q, socketDirectionBytes as qn, HUB_RSS_BUDGET_ENV as qt, defaultProcessGroupOps as r, describeRss as rn, createEventPlaneMeter as rr, createLocalTransport as rt, releaseRunnerGroup as s, reclaimIntervalMs as sn, PeerAnsweredError as st, CAP_METHOD_NOT_IMPLEMENTED as t, createLoopDelayMeter as tn, diffCapActionCensus as tr, __resetCapUsageRegistryForTests as tt, startRunnerParentDeathWatchdog as u, startRunnerHeapWatch as un, encodeFrame as ut, getOrInitReadinessRegistry as v, formatArrayBufferCensus as vn, createAddonService as vt, getMoleculerEventStats as w, heapSpaceField as wn, capServiceName as wt, EVENT_TOPIC_PREFIX as x, HEAP_SPACE_REPORT_MIN_MB as xn, capActionName as xt, getOrInitReadinessRegistryForClient as y, isArrayBufferCensusReport as yn, validateProviderRegistrations as yt, createUdsEventBus as z, createSocketPlaneReader as zn, createAddonDataPlaneFacility as zt };
|