feat: add heap snapshot

This commit is contained in:
Barış Soner Uşaklı
2025-07-11 08:50:53 -04:00
parent e4f56e8392
commit f88329dbbe
6 changed files with 47 additions and 2 deletions

View File

@@ -143,3 +143,21 @@ async function getGitInfo() {
]);
return { hash: hash, hashShort: hash.slice(0, 6), branch: branch };
}
infoController.getHeapdump = async function (req, res) {
const v8 = require('v8');
const path = require('path');
const fs = require('fs');
const filename = path.join(nconf.get('upload_path'), `heapdump-${Date.now()}.heapsnapshot`);
const stored = v8.writeHeapSnapshot(filename, {});
res.download(stored, 'heapdump.heapsnapshot', (err) => {
if (err) {
winston.error(err.stack);
}
fs.unlink(stored, (unlinkErr) => {
if (unlinkErr) {
winston.error(unlinkErr.stack);
}
});
});
};