forked from engineering/cloudservices
fix memory checking issue
parent
4ca2e9b188
commit
271cfe1959
|
@ -15,15 +15,18 @@ export const memoryLimits = {
|
|||
|
||||
export default function memory(client: Client) {
|
||||
setInterval(async () => {
|
||||
try {
|
||||
const accounts = await client.db.Account.find();
|
||||
console.log(accounts);
|
||||
for (const acc of accounts) {
|
||||
console.log(acc);
|
||||
if (acc.root) return;
|
||||
if (acc.root === true) return;
|
||||
// memory in bytes
|
||||
const mem = Number(await client.util.exec(`memory ${acc.username}`)) * 1000;
|
||||
console.log(mem);
|
||||
// memory in megabytes
|
||||
const memoryConversion = mem / 1024 / 1024;
|
||||
console.log(memoryConversion);
|
||||
let userLimits: { soft: number, hard: number };
|
||||
if (acc.tier === 1) {
|
||||
userLimits = { soft: memoryLimits.TIER_1_SOFT, hard: memoryLimits.TIER_1_HARD };
|
||||
|
@ -76,5 +79,8 @@ export default function memory(client: Client) {
|
|||
client.createMessage(channelID, { embed });
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
client.util.handleError(err);
|
||||
}
|
||||
}, 60000);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue