From 9a8f9bb24121a549a7cae10348e05c6023947e2a Mon Sep 17 00:00:00 2001 From: Taha Yassine Kraiem Date: Mon, 19 Sep 2022 18:10:41 +0100 Subject: [PATCH] feat(utilities): heapdump config --- utilities/utils/HeapSnapshot.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/utilities/utils/HeapSnapshot.js b/utilities/utils/HeapSnapshot.js index 818589fcc..6d266c22e 100644 --- a/utilities/utils/HeapSnapshot.js +++ b/utilities/utils/HeapSnapshot.js @@ -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.`); \ No newline at end of file +heapdump && console.log(`HeapSnapshot enabled. Send a request to "/heapdump/new" to generate a heapdump.`); \ No newline at end of file