From 046369532338ba8b683f56ed0936494276c37cc2 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Sun, 27 Aug 2023 19:34:15 -0400 Subject: [PATCH] Improved logging --- Dockerfile | 3 +-- main.js | 2 ++ modules/functions.js | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3562b0d..56dbc78 100755 --- a/Dockerfile +++ b/Dockerfile @@ -5,5 +5,4 @@ WORKDIR /usr/src/app COPY package.json ./ RUN npm install COPY . . -# CMD ["/bin/sh", "-c", "node main.js 2> /logs/silvanus.err 1> /logs/silvanus.log"] -CMD ["/bin/sh", "-c", "node main.js 2> /logs/error/$(date +%Y-%m-%d_%H-%M-%S).txt 1> /logs/status/$(date +%Y-%m-%d_%H-%M-%S).txt"] +CMD ["/bin/sh", "-c", "node main.js 2>&1 > /logs/$(date +%Y-%m-%d_%H-%M-%S).txt"] diff --git a/main.js b/main.js index 1778c9c..2886ce8 100755 --- a/main.js +++ b/main.js @@ -52,6 +52,8 @@ client.once('ready', async () => { fn.sendHeartbeat(heartbeatUrl); }, 30000); if (isDev) console.log("Heartbeat interval set."); + } else { + if (isDev) console.log("No heartbeat URL set, will not send heartbeats for uptime monitoring."); } }); diff --git a/modules/functions.js b/modules/functions.js index 64eec3c..c10491e 100755 --- a/modules/functions.js +++ b/modules/functions.js @@ -1146,11 +1146,13 @@ const functions = { }, async sendHeartbeat(url) { https.get(url, async (response) => { + if (isDev) console.log("Sent Heartbeat Request: " + url); let data = ''; response.on('data', (chunk) => data += chunk); response.on('end', () => { + if (isDev) console.log("Received Heartbeat Response: " + data); parsedData = JSON.parse(data); if ( !(parsedData.ok) ) console.error("Heartbeat failed"); });