v1.2.8 Heartbeat Monitoring #6

Merged
voidf1sh merged 5 commits from v1.2.8 into main 2023-09-02 15:37:13 +00:00
3 changed files with 5 additions and 2 deletions
Showing only changes of commit 0463695323 - Show all commits

View File

@ -5,5 +5,4 @@ WORKDIR /usr/src/app
COPY package.json ./ COPY package.json ./
RUN npm install RUN npm install
COPY . . COPY . .
# CMD ["/bin/sh", "-c", "node main.js 2> /logs/silvanus.err 1> /logs/silvanus.log"] CMD ["/bin/sh", "-c", "node main.js 2>&1 > /logs/$(date +%Y-%m-%d_%H-%M-%S).txt"]
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"]

View File

@ -52,6 +52,8 @@ client.once('ready', async () => {
fn.sendHeartbeat(heartbeatUrl); fn.sendHeartbeat(heartbeatUrl);
}, 30000); }, 30000);
if (isDev) console.log("Heartbeat interval set."); if (isDev) console.log("Heartbeat interval set.");
} else {
if (isDev) console.log("No heartbeat URL set, will not send heartbeats for uptime monitoring.");
} }
}); });

View File

@ -1146,11 +1146,13 @@ const functions = {
}, },
async sendHeartbeat(url) { async sendHeartbeat(url) {
https.get(url, async (response) => { https.get(url, async (response) => {
if (isDev) console.log("Sent Heartbeat Request: " + url);
let data = ''; let data = '';
response.on('data', (chunk) => data += chunk); response.on('data', (chunk) => data += chunk);
response.on('end', () => { response.on('end', () => {
if (isDev) console.log("Received Heartbeat Response: " + data);
parsedData = JSON.parse(data); parsedData = JSON.parse(data);
if ( !(parsedData.ok) ) console.error("Heartbeat failed"); if ( !(parsedData.ok) ) console.error("Heartbeat failed");
}); });