@paigy/harness 0.3.12 → 0.3.13
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/cli.js +30 -4
- package/dist/main.js +30 -4
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -36368,9 +36368,13 @@ function newer(latest, current) {
|
|
|
36368
36368
|
for (let i = 0; i < 3; i++) if (a[i] !== b[i]) return a[i] > b[i];
|
|
36369
36369
|
return false;
|
|
36370
36370
|
}
|
|
36371
|
+
var WAIT_CAP_MS = 6 * 36e5;
|
|
36371
36372
|
function updateAction(o) {
|
|
36372
36373
|
if (!o.service || !o.latest || o.latest === o.failed || !newer(o.latest, o.current)) return "none";
|
|
36373
|
-
|
|
36374
|
+
if (o.sessions <= 0) return "install";
|
|
36375
|
+
const working = o.working ?? o.sessions;
|
|
36376
|
+
if (working > 0) return "wait";
|
|
36377
|
+
return (o.waited ?? 0) >= WAIT_CAP_MS ? "install" : "wait";
|
|
36374
36378
|
}
|
|
36375
36379
|
async function latestVersion() {
|
|
36376
36380
|
const res = await fetch(REGISTRY, { signal: AbortSignal.timeout(1e4) });
|
|
@@ -36389,6 +36393,7 @@ function selfUpdater(deps) {
|
|
|
36389
36393
|
let checkedAt = -Infinity;
|
|
36390
36394
|
let failed;
|
|
36391
36395
|
let waiting = false;
|
|
36396
|
+
let waitingSince = null;
|
|
36392
36397
|
return async () => {
|
|
36393
36398
|
if (!service) return;
|
|
36394
36399
|
const now = (deps.now ?? Date.now)();
|
|
@@ -36396,9 +36401,25 @@ function selfUpdater(deps) {
|
|
|
36396
36401
|
checkedAt = now;
|
|
36397
36402
|
latest = await (deps.latest ?? latestVersion)().catch(() => latest);
|
|
36398
36403
|
}
|
|
36399
|
-
const
|
|
36400
|
-
|
|
36404
|
+
const sessions = deps.sessions();
|
|
36405
|
+
const working = deps.working?.();
|
|
36406
|
+
if (latest && newer(latest, VERSION) && latest !== failed && waitingSince === null) waitingSince = now;
|
|
36407
|
+
const action = updateAction({
|
|
36408
|
+
current: VERSION,
|
|
36409
|
+
latest,
|
|
36410
|
+
service,
|
|
36411
|
+
sessions,
|
|
36412
|
+
failed,
|
|
36413
|
+
...working === void 0 ? {} : { working },
|
|
36414
|
+
waited: waitingSince === null ? 0 : now - waitingSince
|
|
36415
|
+
});
|
|
36416
|
+
if (action === "wait" && !waiting) {
|
|
36417
|
+
deps.log(working ? `\u21E1 @paigy/harness ${latest} is out \u2014 updating once the turn in flight finishes` : `\u21E1 @paigy/harness ${latest} is out \u2014 updating once no session is running (at most ${Math.round(WAIT_CAP_MS / 36e5)}h)`);
|
|
36418
|
+
}
|
|
36401
36419
|
waiting = action === "wait";
|
|
36420
|
+
if (action === "install" && sessions > 0) {
|
|
36421
|
+
deps.log(`\u21E1 @paigy/harness ${latest} is out and ${sessions} resting session(s) have held it for ${Math.round((now - (waitingSince ?? now)) / 36e5)}h \u2014 restarting over them`);
|
|
36422
|
+
}
|
|
36402
36423
|
if (action !== "install" || !latest) return;
|
|
36403
36424
|
try {
|
|
36404
36425
|
await (deps.install ?? install)(latest);
|
|
@@ -36443,7 +36464,12 @@ function startHost(opts) {
|
|
|
36443
36464
|
}
|
|
36444
36465
|
}
|
|
36445
36466
|
};
|
|
36446
|
-
const update = selfUpdater({
|
|
36467
|
+
const update = selfUpdater({
|
|
36468
|
+
sessions: () => runs.size,
|
|
36469
|
+
// A turn in flight blocks the update; a session merely standing by does not hold it forever.
|
|
36470
|
+
working: () => [...runs.values()].filter((r) => r.run.working()).length,
|
|
36471
|
+
log: opts.log
|
|
36472
|
+
});
|
|
36447
36473
|
const beat = () => {
|
|
36448
36474
|
void refreshIdentities();
|
|
36449
36475
|
void update().catch(() => {
|
package/dist/main.js
CHANGED
|
@@ -17076,9 +17076,13 @@ function newer(latest, current) {
|
|
|
17076
17076
|
for (let i = 0; i < 3; i++) if (a[i] !== b[i]) return a[i] > b[i];
|
|
17077
17077
|
return false;
|
|
17078
17078
|
}
|
|
17079
|
+
var WAIT_CAP_MS = 6 * 36e5;
|
|
17079
17080
|
function updateAction(o) {
|
|
17080
17081
|
if (!o.service || !o.latest || o.latest === o.failed || !newer(o.latest, o.current)) return "none";
|
|
17081
|
-
|
|
17082
|
+
if (o.sessions <= 0) return "install";
|
|
17083
|
+
const working = o.working ?? o.sessions;
|
|
17084
|
+
if (working > 0) return "wait";
|
|
17085
|
+
return (o.waited ?? 0) >= WAIT_CAP_MS ? "install" : "wait";
|
|
17082
17086
|
}
|
|
17083
17087
|
async function latestVersion() {
|
|
17084
17088
|
const res = await fetch(REGISTRY, { signal: AbortSignal.timeout(1e4) });
|
|
@@ -17097,6 +17101,7 @@ function selfUpdater(deps) {
|
|
|
17097
17101
|
let checkedAt = -Infinity;
|
|
17098
17102
|
let failed;
|
|
17099
17103
|
let waiting = false;
|
|
17104
|
+
let waitingSince = null;
|
|
17100
17105
|
return async () => {
|
|
17101
17106
|
if (!service) return;
|
|
17102
17107
|
const now = (deps.now ?? Date.now)();
|
|
@@ -17104,9 +17109,25 @@ function selfUpdater(deps) {
|
|
|
17104
17109
|
checkedAt = now;
|
|
17105
17110
|
latest = await (deps.latest ?? latestVersion)().catch(() => latest);
|
|
17106
17111
|
}
|
|
17107
|
-
const
|
|
17108
|
-
|
|
17112
|
+
const sessions = deps.sessions();
|
|
17113
|
+
const working = deps.working?.();
|
|
17114
|
+
if (latest && newer(latest, VERSION) && latest !== failed && waitingSince === null) waitingSince = now;
|
|
17115
|
+
const action = updateAction({
|
|
17116
|
+
current: VERSION,
|
|
17117
|
+
latest,
|
|
17118
|
+
service,
|
|
17119
|
+
sessions,
|
|
17120
|
+
failed,
|
|
17121
|
+
...working === void 0 ? {} : { working },
|
|
17122
|
+
waited: waitingSince === null ? 0 : now - waitingSince
|
|
17123
|
+
});
|
|
17124
|
+
if (action === "wait" && !waiting) {
|
|
17125
|
+
deps.log(working ? `\u21E1 @paigy/harness ${latest} is out \u2014 updating once the turn in flight finishes` : `\u21E1 @paigy/harness ${latest} is out \u2014 updating once no session is running (at most ${Math.round(WAIT_CAP_MS / 36e5)}h)`);
|
|
17126
|
+
}
|
|
17109
17127
|
waiting = action === "wait";
|
|
17128
|
+
if (action === "install" && sessions > 0) {
|
|
17129
|
+
deps.log(`\u21E1 @paigy/harness ${latest} is out and ${sessions} resting session(s) have held it for ${Math.round((now - (waitingSince ?? now)) / 36e5)}h \u2014 restarting over them`);
|
|
17130
|
+
}
|
|
17110
17131
|
if (action !== "install" || !latest) return;
|
|
17111
17132
|
try {
|
|
17112
17133
|
await (deps.install ?? install)(latest);
|
|
@@ -17169,7 +17190,12 @@ function startHost(opts) {
|
|
|
17169
17190
|
}
|
|
17170
17191
|
}
|
|
17171
17192
|
};
|
|
17172
|
-
const update = selfUpdater({
|
|
17193
|
+
const update = selfUpdater({
|
|
17194
|
+
sessions: () => runs.size,
|
|
17195
|
+
// A turn in flight blocks the update; a session merely standing by does not hold it forever.
|
|
17196
|
+
working: () => [...runs.values()].filter((r) => r.run.working()).length,
|
|
17197
|
+
log: opts.log
|
|
17198
|
+
});
|
|
17173
17199
|
const beat = () => {
|
|
17174
17200
|
void refreshIdentities();
|
|
17175
17201
|
void update().catch(() => {
|