From fbb17816b497969dbdbe9224548e97c4b6b69573 Mon Sep 17 00:00:00 2001 From: EarthlingDavey <15802017+EarthlingDavey@users.noreply.github.com> Date: Tue, 3 Dec 2024 17:37:38 +0000 Subject: [PATCH] Reduce logging --- conf/node/controllers/httrack.js | 9 +++++++-- conf/node/controllers/main.js | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/conf/node/controllers/httrack.js b/conf/node/controllers/httrack.js index a98406d..0a573c1 100644 --- a/conf/node/controllers/httrack.js +++ b/conf/node/controllers/httrack.js @@ -211,6 +211,7 @@ export const waitForHttrackComplete = async ( ) => { const intervalSeconds = 1; const maxIterations = timeOutSeconds / intervalSeconds; + const logFrequency = 5 * 60; // Log every 5 minutes let iterations = 0; // Wait for hts-cache/new.txt to exist. @@ -227,9 +228,13 @@ export const waitForHttrackComplete = async ( iterations++ < maxIterations && fs.existsSync(`${dest}/hts-in_progress.lock`) ) { - console.log("Waiting for httrack to complete ... "); + if (iterations < 10 || iterations % logFrequency === 0) { + const elapsedTime = new Date(iterations * intervalSeconds * 1000).toISOString().substring(11, 19); + console.log( + `Waiting for httrack to complete ... ${elapsedTime} elapsed`, + ); + } await new Promise((resolve) => setTimeout(resolve, intervalSeconds * 1000)); - iterations++; } return { diff --git a/conf/node/controllers/main.js b/conf/node/controllers/main.js index 49c7cf9..8c03a6b 100644 --- a/conf/node/controllers/main.js +++ b/conf/node/controllers/main.js @@ -43,5 +43,5 @@ export const main = async ({ url, agency, depth }) => { // Clean up the snapshot directory await fs.rm(paths.fs, { recursive: true, force: true }); - console.log("Snapshot complete", { url, agency, depth }); + console.log("Snapshot complete", { url: url.href, agency, depth }); };