Use setInterval
All checks were successful
CI / CI (push) Successful in 1m24s

This commit is contained in:
SileNce5k 2025-06-25 05:08:43 +02:00
parent a54361c571
commit c100528c2a
Signed by: SileNce
GPG key ID: B0A142BB4291B204
2 changed files with 3 additions and 3 deletions

View file

@ -14,5 +14,7 @@ module.exports = function(client, enableLoginMessage, loginChannel, loginMessage
}
loadServerPrefixes(client)
checkTimer(client);
updateCpuPercentage(client.processInfo);
setInterval(() => {
updateCpuPercentage(client)
}, 60 * 1000);
}

View file

@ -1,10 +1,8 @@
const os = require('os');
const updateCpuPercentage = require('./updateCpuPercentage');
module.exports = async function (processInfo) {
const newCpuUsage = process.cpuUsage(processInfo.cpuPercentage);
processInfo.previousCpuUsage = process.cpuUsage();
processInfo.cpuPercentage = (newCpuUsage.system + newCpuUsage.user) / 60_000_000 / os.cpus().length;
setTimeout(updateCpuPercentage, 60000, processInfo);
}