From 3b958a02ef9b0f68e774576af8fede47f83aa3d2 Mon Sep 17 00:00:00 2001 From: DebaucheryLibrarian Date: Mon, 27 Dec 2021 22:36:01 +0100 Subject: [PATCH] Added memory profiler configuration options. --- config/default.js | 4 ++++ src/app.js | 3 ++- src/argv.js | 6 ++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/config/default.js b/config/default.js index 0a865a94f..61e44d46d 100644 --- a/config/default.js +++ b/config/default.js @@ -316,6 +316,10 @@ module.exports = { }, fetchAfter: [1, 'week'], missingDateLimit: 3, + memorySampling: { + enabled: false, + snapshotIntervals: [], + }, media: { path: './media', thumbnailSize: 320, // width for 16:9 will be exactly 576px diff --git a/src/app.js b/src/app.js index 18c2ecf85..430308922 100644 --- a/src/app.js +++ b/src/app.js @@ -1,5 +1,6 @@ 'use strict'; +const config = require('config'); const util = require('util'); const log = require('why-is-node-running'); const Inspector = require('inspector-api'); @@ -84,7 +85,7 @@ async function startMemorySample(snapshotTriggers = []) { async function init() { try { if (argv.sampleMemory) { - await startMemorySample([1000]); + await startMemorySample(config.memorySampling.snapshotIntervals); } if (argv.logActive) { diff --git a/src/argv.js b/src/argv.js index de0d3fef9..42522bd08 100644 --- a/src/argv.js +++ b/src/argv.js @@ -247,6 +247,12 @@ const { argv } = yargs type: 'boolean', default: process.env.NODE_ENV === 'development', }) + .option('sampleMemory', { + alias: 'memory', + describe: 'Take memory allocation samples, and snapshots at configured intervals', + type: 'boolean', + default: config.memorySampling.enabled, + }) .option('update-search', { describe: 'Update search documents for all releases.', type: 'boolean',