mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 03:59:50 +02:00
save on exit
This commit is contained in:
1 parent
ffd74de79f
commit
6d527a7170
1 file changed
+12
@@ -135,6 +135,9 @@ for (const region of regions) {
|
|||||||
|
|
||||||
console.log("Starting discovery loop...");
|
console.log("Starting discovery loop...");
|
||||||
|
|
||||||
|
process.on("SIGINT", save);
|
||||||
|
process.on("SIGTERM", save);
|
||||||
|
|
||||||
const queue: { region: RegionDescriptor; url: string; size: number }[] = [];
|
const queue: { region: RegionDescriptor; url: string; size: number }[] = [];
|
||||||
const applicationId = import.meta.env.PUBLIC_WARGAMING_APPLICATION_ID;
|
const applicationId = import.meta.env.PUBLIC_WARGAMING_APPLICATION_ID;
|
||||||
const fields = "account_id%2C-account_id";
|
const fields = "account_id%2C-account_id";
|
||||||
@@ -225,6 +228,12 @@ while (performance.now() < t1 && regions.length > 0) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let isSaving = false;
|
||||||
|
async function save() {
|
||||||
|
if (isSaving) return;
|
||||||
|
|
||||||
|
isSaving = true;
|
||||||
|
|
||||||
console.log("Saving chunks...");
|
console.log("Saving chunks...");
|
||||||
|
|
||||||
await rm(`${CHUNKS_DIR}/*`, { force: true });
|
await rm(`${CHUNKS_DIR}/*`, { force: true });
|
||||||
@@ -251,3 +260,6 @@ await git`git push --force-with-lease`.quiet();
|
|||||||
console.log(
|
console.log(
|
||||||
`Committed ${totalFound.toLocaleString()} total ids across ${chunkCount} chunks`,
|
`Committed ${totalFound.toLocaleString()} total ids across ${chunkCount} chunks`,
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
await save();
|
||||||
Reference in new issue
Block a user