mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-22 13:38:31 +00:00
Feat : Auto restart after crash
This commit is contained in:
+5
-2
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user