fix server ram recalc

This commit is contained in:
Olivier Gagnon 2021-10-08 23:45:54 -04:00
parent a2599f19d7
commit bbf3a1d19a
4 changed files with 20 additions and 25 deletions

26
dist/vendor.bundle.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -90,15 +90,6 @@ function removeWorkerScript(workerScript: WorkerScript, rerenderUi = true): void
return; return;
} }
// Recalculate ram used on that server
server.ramUsed = roundToTwo(server.ramUsed - workerScript.ramUsage);
if (server.ramUsed < 0) {
console.warn(
`Server (${server.hostname}) RAM usage went negative (if it's due to floating pt imprecision, it's okay): ${server.ramUsed}`,
);
server.ramUsed = 0;
}
// Delete the RunningScript object from that server // Delete the RunningScript object from that server
for (let i = 0; i < server.runningScripts.length; ++i) { for (let i = 0; i < server.runningScripts.length; ++i) {
const runningScript = server.runningScripts[i]; const runningScript = server.runningScripts[i];
@ -108,6 +99,10 @@ function removeWorkerScript(workerScript: WorkerScript, rerenderUi = true): void
} }
} }
// Recalculate ram used on that server
server.ramUsed = 0;
for (const rs of server.runningScripts) server.ramUsed += rs.ramUsage;
// Delete script from global pool (workerScripts) // Delete script from global pool (workerScripts)
const res = workerScripts.delete(workerScript.pid); const res = workerScripts.delete(workerScript.pid);
if (!res) { if (!res) {