@tablation/crew 0.152.1 → 0.152.2
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 +55 -19
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -4151,6 +4151,7 @@ var SHIP_KEYS = /* @__PURE__ */ new Set([
|
|
|
4151
4151
|
"roleConcurrency",
|
|
4152
4152
|
"streamRetentionDays",
|
|
4153
4153
|
"eventsRotateBytes",
|
|
4154
|
+
"stateMaxBytes",
|
|
4154
4155
|
"reposBasePath",
|
|
4155
4156
|
"relayHost",
|
|
4156
4157
|
"relayPort",
|
|
@@ -4508,6 +4509,10 @@ Create the first of those:
|
|
|
4508
4509
|
if (!Number.isInteger(streamRetentionDays) || streamRetentionDays < 1) {
|
|
4509
4510
|
missing.add(`ship.streamRetentionDays must be a positive integer (got "${shipRaw.streamRetentionDays}")`);
|
|
4510
4511
|
}
|
|
4512
|
+
const stateMaxBytes = shipRaw.stateMaxBytes === void 0 ? 2 * 1024 * 1024 * 1024 : Number(shipRaw.stateMaxBytes);
|
|
4513
|
+
if (!Number.isInteger(stateMaxBytes) || stateMaxBytes < 1) {
|
|
4514
|
+
missing.add(`ship.stateMaxBytes must be a positive integer (got "${shipRaw.stateMaxBytes}")`);
|
|
4515
|
+
}
|
|
4511
4516
|
const maxPeriscopes = shipRaw.maxPeriscopes === void 0 ? DEFAULT_MAX_PERISCOPES : Number(shipRaw.maxPeriscopes);
|
|
4512
4517
|
if (!Number.isInteger(maxPeriscopes) || maxPeriscopes < 1) {
|
|
4513
4518
|
missing.add(`ship.maxPeriscopes must be a positive integer (got "${shipRaw.maxPeriscopes}")`);
|
|
@@ -4606,6 +4611,7 @@ Create the first of those:
|
|
|
4606
4611
|
roleConcurrency,
|
|
4607
4612
|
streamRetentionDays,
|
|
4608
4613
|
eventsRotateBytes,
|
|
4614
|
+
stateMaxBytes,
|
|
4609
4615
|
relayHost: shipRaw.relayHost ? String(shipRaw.relayHost) : void 0,
|
|
4610
4616
|
// 2222 matches the relay's own RELAY_SSH_PORT default (crew-relay README).
|
|
4611
4617
|
relayPort: shipRaw.relayPort !== void 0 ? Number(shipRaw.relayPort) : 2222,
|
|
@@ -27302,6 +27308,38 @@ function planEventsSweep(stateDir, retentionDays, now = Date.now()) {
|
|
|
27302
27308
|
}
|
|
27303
27309
|
}).sort();
|
|
27304
27310
|
}
|
|
27311
|
+
function planSizeCapSweep(stateDir, maxBytes, now = Date.now()) {
|
|
27312
|
+
const files = [];
|
|
27313
|
+
const add = (dir, keep) => {
|
|
27314
|
+
if (!existsSync55(dir)) return;
|
|
27315
|
+
for (const name of readdirSync17(dir)) {
|
|
27316
|
+
if (!keep(name)) continue;
|
|
27317
|
+
const path = join58(dir, name);
|
|
27318
|
+
try {
|
|
27319
|
+
const st = statSync16(path);
|
|
27320
|
+
if (st.isFile()) files.push({ path, mtime: st.mtimeMs, size: st.size });
|
|
27321
|
+
} catch {
|
|
27322
|
+
}
|
|
27323
|
+
}
|
|
27324
|
+
};
|
|
27325
|
+
add(join58(stateDir, "streams"), () => true);
|
|
27326
|
+
add(stateDir, (name) => ROTATED_EVENTS_RE.test(name));
|
|
27327
|
+
let total = files.reduce((n, f) => n + f.size, 0);
|
|
27328
|
+
const out = [];
|
|
27329
|
+
for (const f of files.sort((a, b) => a.mtime - b.mtime)) {
|
|
27330
|
+
if (total <= maxBytes) break;
|
|
27331
|
+
if (f.mtime > now - DAY_MS2) break;
|
|
27332
|
+
out.push(f.path);
|
|
27333
|
+
total -= f.size;
|
|
27334
|
+
}
|
|
27335
|
+
return out;
|
|
27336
|
+
}
|
|
27337
|
+
function planStateSweep(stateDir, retentionDays, maxBytes, now = Date.now()) {
|
|
27338
|
+
const aged = [...planStreamSweep(stateDir, retentionDays, now), ...planEventsSweep(stateDir, retentionDays, now)];
|
|
27339
|
+
const gone = new Set(aged);
|
|
27340
|
+
const capped = planSizeCapSweep(stateDir, maxBytes, now).filter((p) => !gone.has(p));
|
|
27341
|
+
return [...aged, ...capped];
|
|
27342
|
+
}
|
|
27305
27343
|
|
|
27306
27344
|
// src/cli.ts
|
|
27307
27345
|
import { realpathSync as realpathSync3, readFileSync as readFileSync57, existsSync as existsSync60, mkdirSync as mkdirSync43, writeFileSync as writeFileSync44, rmSync as rmSync27, unlinkSync as unlinkSync6, copyFileSync as copyFileSync2, renameSync as renameSync10, statSync as statSync19, readdirSync as readdirSync22 } from "fs";
|
|
@@ -27383,7 +27421,7 @@ import { dirname as dirOf2, resolve as resolvePath } from "path";
|
|
|
27383
27421
|
import { existsSync as existsSync56, readdirSync as readdirSync18, statSync as statSync17 } from "fs";
|
|
27384
27422
|
import { join as join59 } from "path";
|
|
27385
27423
|
function builtVersion() {
|
|
27386
|
-
return true ? "0.152.
|
|
27424
|
+
return true ? "0.152.2" : null;
|
|
27387
27425
|
}
|
|
27388
27426
|
var REBUILD_HINT = "rebuild with npm run build";
|
|
27389
27427
|
function newestMtime(path) {
|
|
@@ -29995,6 +30033,17 @@ if (command === "passenger-sync-daemon") {
|
|
|
29995
30033
|
controlUrlFor: (slug2) => `${relayBaseUrlFor(slug2, relayHost, cfg.ship.relayHttpPort, cfg.ship.relayPublicDomain)}/control`,
|
|
29996
30034
|
warn: (m) => emit.warn(m, { step: "passengers" })
|
|
29997
30035
|
};
|
|
30036
|
+
}, sweepStateDir = function() {
|
|
30037
|
+
try {
|
|
30038
|
+
const paths = planStateSweep(cfg.ship.stateDir, cfg.ship.streamRetentionDays, cfg.ship.stateMaxBytes);
|
|
30039
|
+
if (paths.length) {
|
|
30040
|
+
emit.enter("worktree");
|
|
30041
|
+
const removed = applyStreamSweep(paths, dryRun, emit);
|
|
30042
|
+
emit.emit(`swept ${removed} stream artifact(s)`, { step: "worktree" });
|
|
30043
|
+
}
|
|
30044
|
+
} catch (e) {
|
|
30045
|
+
emit.warn(`stream sweep failed: ${e.message}`, { step: "worktree" });
|
|
30046
|
+
}
|
|
29998
30047
|
}, releaseRefused = function() {
|
|
29999
30048
|
const why = state.releaseSkipReason();
|
|
30000
30049
|
if (!why) return false;
|
|
@@ -30066,7 +30115,7 @@ if (command === "passenger-sync-daemon") {
|
|
|
30066
30115
|
}
|
|
30067
30116
|
};
|
|
30068
30117
|
};
|
|
30069
|
-
routineLine2 = routineLine, die2 = die, requireArmed2 = requireArmed, parseTicketNumber2 = parseTicketNumber, routeRelayUrl2 = routeRelayUrl, previewRelayFor2 = previewRelayFor, passengerApiKeys2 = passengerApiKeys, endpointApiFor2 = endpointApiFor, periscopeEndpointDeps2 = periscopeEndpointDeps, periscopeMcpDeps2 = periscopeMcpDeps, endpointReconcileDeps2 = endpointReconcileDeps, releaseRefused2 = releaseRefused, doctorMachineId2 = doctorMachineId, baseHealth2 = baseHealth, sandboxCacheRepos2 = sandboxCacheRepos, buildSandboxCachePass2 = buildSandboxCachePass, sandboxTickDeps2 = sandboxTickDeps;
|
|
30118
|
+
routineLine2 = routineLine, die2 = die, requireArmed2 = requireArmed, parseTicketNumber2 = parseTicketNumber, routeRelayUrl2 = routeRelayUrl, previewRelayFor2 = previewRelayFor, passengerApiKeys2 = passengerApiKeys, endpointApiFor2 = endpointApiFor, periscopeEndpointDeps2 = periscopeEndpointDeps, periscopeMcpDeps2 = periscopeMcpDeps, endpointReconcileDeps2 = endpointReconcileDeps, sweepStateDir2 = sweepStateDir, releaseRefused2 = releaseRefused, doctorMachineId2 = doctorMachineId, baseHealth2 = baseHealth, sandboxCacheRepos2 = sandboxCacheRepos, buildSandboxCachePass2 = buildSandboxCachePass, sandboxTickDeps2 = sandboxTickDeps;
|
|
30070
30119
|
async function failDaemonStart(o) {
|
|
30071
30120
|
const failEmit = new Emitter({
|
|
30072
30121
|
route: "",
|
|
@@ -30420,6 +30469,7 @@ if (command === "passenger-sync-daemon") {
|
|
|
30420
30469
|
}
|
|
30421
30470
|
}
|
|
30422
30471
|
async function releaseFleet(opts = {}) {
|
|
30472
|
+
sweepStateDir();
|
|
30423
30473
|
if (releaseRefused()) return;
|
|
30424
30474
|
precheckTickets.clear();
|
|
30425
30475
|
const summaries = [];
|
|
@@ -30445,19 +30495,7 @@ if (command === "passenger-sync-daemon") {
|
|
|
30445
30495
|
for (const t of chosen) summaries.push({ ...await releasePhase(route2, t, opts), route: route2.route });
|
|
30446
30496
|
emitReleaseSummary(emit, summaries);
|
|
30447
30497
|
if (!dryRun) state.releaseHeartbeat().touch();
|
|
30448
|
-
|
|
30449
|
-
const paths = [
|
|
30450
|
-
...planStreamSweep(cfg.ship.stateDir, cfg.ship.streamRetentionDays),
|
|
30451
|
-
...planEventsSweep(cfg.ship.stateDir, cfg.ship.streamRetentionDays)
|
|
30452
|
-
];
|
|
30453
|
-
if (paths.length) {
|
|
30454
|
-
emit.enter("worktree");
|
|
30455
|
-
const removed = applyStreamSweep(paths, dryRun, emit);
|
|
30456
|
-
emit.emit(`swept ${removed} stream artifact(s)`, { step: "worktree" });
|
|
30457
|
-
}
|
|
30458
|
-
} catch (e) {
|
|
30459
|
-
emit.warn(`stream sweep failed: ${e.message}`, { step: "worktree" });
|
|
30460
|
-
}
|
|
30498
|
+
sweepStateDir();
|
|
30461
30499
|
}
|
|
30462
30500
|
const repoRowCache = /* @__PURE__ */ new Map();
|
|
30463
30501
|
const projectRowCache = /* @__PURE__ */ new Map();
|
|
@@ -33882,10 +33920,7 @@ ${found.problems.map((p) => ` - ${p}`).join("\n")}`);
|
|
|
33882
33920
|
emit.emit(`rotated oversized event log to ${rotated}`, { step: "worktree" });
|
|
33883
33921
|
}
|
|
33884
33922
|
}
|
|
33885
|
-
const streamPaths =
|
|
33886
|
-
...planStreamSweep(cfg.ship.stateDir, cfg.ship.streamRetentionDays),
|
|
33887
|
-
...planEventsSweep(cfg.ship.stateDir, cfg.ship.streamRetentionDays)
|
|
33888
|
-
];
|
|
33923
|
+
const streamPaths = planStateSweep(cfg.ship.stateDir, cfg.ship.streamRetentionDays, cfg.ship.stateMaxBytes);
|
|
33889
33924
|
if (streamPaths.length) {
|
|
33890
33925
|
anything = true;
|
|
33891
33926
|
const removed = applyStreamSweep(streamPaths, dryRun, emit);
|
|
@@ -36113,6 +36148,7 @@ var endpointApiFor2;
|
|
|
36113
36148
|
var periscopeEndpointDeps2;
|
|
36114
36149
|
var periscopeMcpDeps2;
|
|
36115
36150
|
var endpointReconcileDeps2;
|
|
36151
|
+
var sweepStateDir2;
|
|
36116
36152
|
var releaseRefused2;
|
|
36117
36153
|
var doctorMachineId2;
|
|
36118
36154
|
var baseHealth2;
|
package/package.json
CHANGED