perf: save only changed accounts, cache missing assets, lighter logging and backup

Ping on prod jumped to seconds because node's main thread was busy most
of every second.

- accounts.save(account, ...) names the changed accounts, which are
  written within a second; the rest are looked at a few at a time
  (10 ms a save for those in play, 5 ms for the others). One save under
  prod-like load: 289 ms before, 16 ms after.
- an asset the CDN does not have gets a cacheable 404 and is logged once
- the proxy's own connections no longer count against the web cap, which
  had node reset requests nginx had already let in
- a repeated client error is written once in ten minutes; the panel's
  log buffer trims in batches
- the daily backup uses sqlite's online backup off the main thread
This commit is contained in:
Burrowdev committed 2026-10-17 11:57:40 +03:00
1 parent edca7bf790
commit aa455f52d0
26 files changed
+334 -220

No files matched your search

+7 -7
View File
@@ -71,7 +71,7 @@ module.exports = ({findOnline}) => {
target.banReason = bans.reasonText(reason);
target.bannedBy = by;
target.bannedAt = now();
accounts.save();
accounts.save(target);
bans.record({account: target, action: "ban", seconds: duration, reason: target.banReason, by});
const session = findOnline(target.username);
if (session) {
@@ -87,7 +87,7 @@ module.exports = ({findOnline}) => {
delete target.banReason;
delete target.bannedBy;
delete target.bannedAt;
accounts.save();
accounts.save(target);
if (was) {
bans.record({account: target, action: "unban", by});
}
@@ -100,7 +100,7 @@ module.exports = ({findOnline}) => {
return false;
}
target.banReason = bans.reasonText(reason);
accounts.save();
accounts.save(target);
bans.record({account: target, action: "reason", reason: target.banReason, by});
return true;
},
@@ -108,7 +108,7 @@ module.exports = ({findOnline}) => {
// duration in seconds, PERMANENT, or 0 to lift
silence(target, duration) {
target.silencedUntil = duration === PERMANENT ? PERMANENT : (duration > 0 ? now() + duration : 0);
accounts.save();
accounts.save(target);
const session = findOnline(target.username);
if (session) {
// minutes, negative for "until further notice", 0 for "you may type again"
@@ -123,7 +123,7 @@ module.exports = ({findOnline}) => {
rejectName(target, by = "") {
target.nameRejected = {by, at: now()};
accounts.revokeTokens(target);
accounts.save();
accounts.save(target);
actions.kick(target);
return true;
},
@@ -131,7 +131,7 @@ module.exports = ({findOnline}) => {
// taken back: the name will do after all.
acceptName(target) {
delete target.nameRejected;
accounts.save();
accounts.save(target);
return true;
},
@@ -154,7 +154,7 @@ module.exports = ({findOnline}) => {
const before = target.currency[name] || 0;
target.currency[name] = Math.max(0, before + amount);
achievements.currencyChanged(target, name, target.currency[name] - before);
accounts.save();
accounts.save(target);
const session = findOnline(target.username);
if (session) {
// ItemXtCommManager.currencyUpdateResponse: [currencyType, newAmount, reason]