feat(studio): run nitro scans in the background with cancel-re-attach and nightly auto-clean

This commit is contained in:
openhands committed 2026-09-19 13:41:14 +02:00
1 parent 9d571e0c29
commit 6c53f4680c
14 files changed
+1547 -303

No files matched your search

+31
View File
@@ -19,6 +19,7 @@ import {
parseDfOutput,
} from "../src/lib/services/disk-usage";
import { publishDueArticles } from "../src/lib/services/news-scheduler";
import { scheduledAutoCleanFakeNitros } from "../src/lib/services/nitro-cleanup";
import { rcon } from "../src/lib/services/rcon";
function captureWorkerError(err: unknown, context: string): void {
@@ -353,6 +354,27 @@ async function publishScheduledArticles(): Promise<void> {
}
}
/** Nightly self-cleaning of old fake .nitro leftovers (skips when a scan is
* running in the studio). Requires the `items_base` truth list, so a DB outage
* shows up here as a captured error instead of deleting anything. */
async function autoCleanNitroFakes(): Promise<void> {
try {
const result = await scheduledAutoCleanFakeNitros(30);
if (result.skipped) {
logger.info("Skipped nightly nitro auto-clean: scan in progress", {
module: "jobs",
});
} else {
logger.info("Nightly nitro auto-clean finished", {
module: "jobs",
deleted: result.deleted,
});
}
} catch (err) {
captureWorkerError(err, "Nitro auto-clean failed");
}
}
async function reportWorkerHeartbeat(): Promise<void> {
if (!redis) return;
await redis
@@ -433,6 +455,15 @@ async function main() {
void reportWorkerHeartbeat();
});
await reportWorkerHeartbeat();
new Cron("0 2 * * *", () => {
autoCleanNitroFakes().catch((e) =>
captureWorkerError(e, "Nitro auto-clean error"),
);
});
logger.info("Scheduled: nitro auto-clean (daily 02:00)", {
module: "jobs",
});
await Promise.all([
backupEmulatorJar(),
cleanupOldLogs(),