@nodii/dev 0.6.87 → 0.6.88
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/core.js +1 -1
- package/dist/watchdog.js +27 -2
- package/package.json +1 -1
package/dist/core.js
CHANGED
|
@@ -4,7 +4,7 @@ import { chmod, mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
|
4
4
|
import { homedir, platform } from "node:os";
|
|
5
5
|
import { dirname, join } from "node:path";
|
|
6
6
|
|
|
7
|
-
export const VERSION = "0.6.
|
|
7
|
+
export const VERSION = "0.6.88";
|
|
8
8
|
export const configPath = () =>
|
|
9
9
|
process.env.NODII_DEV_CONFIG_PATH ??
|
|
10
10
|
join(homedir(), ".config/nodii-dev/config.json");
|
package/dist/watchdog.js
CHANGED
|
@@ -5,7 +5,7 @@ import { dirname, isAbsolute, join, resolve } from "node:path";
|
|
|
5
5
|
import { promisify } from "node:util";
|
|
6
6
|
import { CliError, configPath, devRequest, encode, readConfig } from "./core.js";
|
|
7
7
|
import { USAGE_REFRESH_MS, listAccounts, reportUsage } from "./accounts.js";
|
|
8
|
-
import { laneCloseout } from "./lanes.js";
|
|
8
|
+
import { laneCloseout, laneCommand } from "./lanes.js";
|
|
9
9
|
|
|
10
10
|
const execFile = promisify(execFileCallback);
|
|
11
11
|
export const WATCHDOG_LABEL = "com.nodii.watchdog";
|
|
@@ -236,6 +236,9 @@ export async function laneCapReminder({ home = homedir() } = {}) {
|
|
|
236
236
|
catch { return null; }
|
|
237
237
|
}
|
|
238
238
|
|
|
239
|
+
/** hub-251: resume-due lanes one sweep resumes at most, so a cleared fan-in never launches a burst. */
|
|
240
|
+
export const RESUME_DUE_PER_SWEEP = 3;
|
|
241
|
+
|
|
239
242
|
/** One launchd sweep. The machine coordinator reports every observation through Dev's run watchdog contract. */
|
|
240
243
|
export async function sweepWatchdog({
|
|
241
244
|
records,
|
|
@@ -248,6 +251,7 @@ export async function sweepWatchdog({
|
|
|
248
251
|
refreshUsage = refreshMachineUsage,
|
|
249
252
|
closeout = laneCloseout,
|
|
250
253
|
saveReminder = saveLaneCapReminder,
|
|
254
|
+
resumeLane = (key, deps) => laneCommand("resume", [key], {}, deps),
|
|
251
255
|
} = {}) {
|
|
252
256
|
const loaded = records ? { records, errors: [] } : await loadRecords();
|
|
253
257
|
const facts = await collect(loaded.records, { errors: [...loaded.errors] });
|
|
@@ -367,7 +371,28 @@ export async function sweepWatchdog({
|
|
|
367
371
|
} catch (error) {
|
|
368
372
|
facts.errors.push({ kind: "lane_cap", code: error?.code ?? "LANE_CAP_READ_FAILED" });
|
|
369
373
|
}
|
|
370
|
-
|
|
374
|
+
// hub-251: a lane whose wait cleared (the lane it waited on merged, reached
|
|
375
|
+
// dev or ended) and that no process works is resume due. Dev decides which;
|
|
376
|
+
// this Mac resumes them, a few per sweep, and lane resume keeps the machine's
|
|
377
|
+
// lane cap, governor and one-process rule. A refusal is reported, not fatal.
|
|
378
|
+
const resumed = [];
|
|
379
|
+
try {
|
|
380
|
+
const due = (await request("GET", `/api/v1/lanes?machine=${encode(effectiveMachineId)}&resume-due=true&limit=${RESUME_DUE_PER_SWEEP}`))?.data;
|
|
381
|
+
// Only a row Dev marks resumeDue: a Dev that does not know the filter
|
|
382
|
+
// lists every lane, and none of them is resumed.
|
|
383
|
+
const marked = (Array.isArray(due) ? due : []).filter((lane) => lane?.resumeDue === true);
|
|
384
|
+
for (const lane of marked.slice(0, RESUME_DUE_PER_SWEEP)) {
|
|
385
|
+
try {
|
|
386
|
+
await resumeLane(lane.key, { request });
|
|
387
|
+
resumed.push({ laneId: lane.id, key: lane.key });
|
|
388
|
+
} catch (error) {
|
|
389
|
+
facts.errors.push({ kind: "resume", laneKey: lane.key, code: error?.code ?? "LANE_RESUME_FAILED" });
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
} catch (error) {
|
|
393
|
+
facts.errors.push({ kind: "resume_due", code: error?.code ?? "RESUME_DUE_READ_FAILED" });
|
|
394
|
+
}
|
|
395
|
+
const report = { ...facts, orphanedRuns, finalOrphanCloseouts, unwatchedRuns, accounts, laneCap, resumed };
|
|
371
396
|
return report;
|
|
372
397
|
}
|
|
373
398
|
|