Feat : Auto restart after crash

This commit is contained in:
decolua
2026-03-14 09:37:29 +07:00
parent 549223c8cf
commit adae2605bf
31 changed files with 340 additions and 189 deletions
+5 -2
View File
@@ -245,8 +245,11 @@ export async function saveRequestUsage(entry) {
entry.cost = entryCost;
db.data.history.push(entry);
// Optional: Limit history size if needed in future
// if (db.data.history.length > 10000) db.data.history.shift();
// Cap history to prevent unbounded memory/disk growth
const MAX_HISTORY = 10000;
if (db.data.history.length > MAX_HISTORY) {
db.data.history.splice(0, db.data.history.length - MAX_HISTORY);
}
await db.write();
statsEmitter.emit("update");