fix: change memory monitor to csv-like

This commit is contained in:
diced
2025-11-11 22:17:46 -08:00
parent 63c268cd1e
commit 89d6b2908d
2 changed files with 4 additions and 10 deletions

2
.gitignore vendored
View File

@@ -49,4 +49,4 @@ uploads*/
*.crt *.crt
*.key *.key
src/prisma src/prisma
.memory.log.json .memory.log*

View File

@@ -286,20 +286,14 @@ async function main() {
tasks.start(); tasks.start();
if (process.env.DEBUG_MONITOR_MEMORY === 'true') { if (process.env.DEBUG_MONITOR_MEMORY === 'true') {
await writeFile('.memory.log.json', '', 'utf8'); await writeFile('.memory.log', '', 'utf8');
setInterval(async () => { setInterval(async () => {
const mu = process.memoryUsage(); const mu = process.memoryUsage();
const cpu = process.cpuUsage(); const cpu = process.cpuUsage();
const entry = { const entry = `${Math.floor(Date.now() / 1000)},${mu.rss},${mu.heapUsed},${mu.heapTotal},${mu.external},${mu.arrayBuffers},${cpu.system},${cpu.user}\n`;
timestamp: new Date().toISOString(),
data: {
memoryUsage: mu,
cpuUsage: cpu,
},
};
await appendFile('.memory.log.json', JSON.stringify(entry) + '\n', 'utf8'); await appendFile('.memory.log', entry, 'utf8');
}, 1000); }, 1000);
} }
} }