Reconcile stale running scrapes and allow per-scrape delete
This commit is contained in:
@@ -208,6 +208,25 @@ export class ScrapeEngine {
|
||||
return { ...meta };
|
||||
}
|
||||
|
||||
/**
|
||||
* A scrape left `running` or `queued` on disk has no live job (the daemon that owned it is
|
||||
* gone). Pause it so the UI shows the truth and Resume can pick it up.
|
||||
*/
|
||||
reconcileStaleJobs(): string[] {
|
||||
const stale: string[] = [];
|
||||
|
||||
for (const meta of listScrapes(this.options.rootDir)) {
|
||||
if (meta.state !== "running" && meta.state !== "queued") continue;
|
||||
|
||||
meta.state = "paused";
|
||||
meta.updatedAt = new Date(this.now()).toISOString();
|
||||
writeScrapeMeta(join(this.options.rootDir, meta.id), meta);
|
||||
stale.push(meta.id);
|
||||
}
|
||||
|
||||
return stale;
|
||||
}
|
||||
|
||||
/** Cache previews for rows a finished or paused scrape never reached. Returns the count. */
|
||||
async backfillPreviews(scrapeId: string): Promise<number> {
|
||||
const meta = this.active.get(scrapeId) ?? readScrapeMeta(join(this.options.rootDir, scrapeId));
|
||||
|
||||
Reference in New Issue
Block a user