Merge remote-tracking branch 'origin/api-v1.5.5' into dev

This commit is contained in:
Taha Yassine Kraiem 2022-04-11 15:45:47 +02:00
commit 72b9cf4cee

View file

@ -15,20 +15,14 @@ async function createHeapSnapshot() {
async function sendHeapSnapshot(req, res) {
const fileName = await createHeapSnapshot();
const file = fs.readFileSync(location + fileName, 'binary');
const stat = fs.statSync(location + fileName);
res.setHeader('Content-Length', stat.size);
res.setHeader('Content-Type', 'audio/mpeg');
res.setHeader('Content-Disposition', 'attachment; filename=' + fileName);
res.write(file, 'binary');
res.end();
try {
fs.unlinkSync(location + fileName)
} catch (err) {
console.error("error while deleting heapsnapshot file");
console.error(err);
}
res.download(location + fileName, function (err) {
try {
fs.unlinkSync(location + fileName)
} catch (err) {
console.error("error while deleting heapsnapshot file");
console.error(err);
}
});
}
process.on('USR2', () => {