feat(utilities): heapdump config

This commit is contained in:
Taha Yassine Kraiem 2022-09-19 18:10:41 +01:00
parent 1984115250
commit 9a8f9bb241

View file

@ -3,6 +3,7 @@ const v8 = require('v8');
const express = require('express');
const router = express.Router();
const heapdump = process.env.heapdump === "1";
const location = '/tmp/';
let creationStatus = null;
let fileName = null;
@ -60,9 +61,11 @@ function createNewHeapSnapshot(req, res) {
res.end(JSON.stringify({path: location + fileName, 'done': creationStatus}));
}
router.get(`/status`, getHeapSnapshotStatus);
router.get(`/new`, createNewHeapSnapshot);
router.get(`/download`, downloadHeapSnapshot);
if (heapdump) {
router.get(`/status`, getHeapSnapshotStatus);
router.get(`/new`, createNewHeapSnapshot);
router.get(`/download`, downloadHeapSnapshot);
}
module.exports = {router}
console.log(`HeapSnapshot enabled. Send a request to "/heapdump/new" to generate a heapdump.`);
heapdump && console.log(`HeapSnapshot enabled. Send a request to "/heapdump/new" to generate a heapdump.`);