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
5 changed files with 21 additions and 15 deletions

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"]

24
TODO.md
View File

@ -1,10 +1,3 @@
## In Progress
☑ Switch `/setup` to ask for the tree and leaderboard channels
* Switch `/compare` to check for newer trees and leaderboards when run **and** on every refresh
## Future Ideas
* Go through and comment the code
## Variable Structures ## Variable Structures
guildInfo = { guildInfo = {
@ -21,7 +14,18 @@ guildInfo = {
reminderOptIn: 0, reminderOptIn: 0,
} }
## Expected Behaviors ## New Table Planning
Table: `silvanus`.timers
* Run `/compare` before `/setup`: `/compare` will search the current channel for tree and leaderboard messages, then create a comparison embed. If it can't find `/tree` or `/top trees` messages, it'll return an error saying as much. id | INT | NOT NULL | AUTO INCREMENT | PRIMARY KEY
* Run `/compare` after `/setup`: ``/compare` will search the current channel for tree and leaderboard messages, then create a comparison embed. If it can't find `/tree` or `/top trees` messages, it'll just use old data silently (odds are `/compare` is being run from another channel, that's fine) status | VARCHAR(10) | NOT NULL | DEFAULT "WAITING"
dc_timecode | INT | NOT NULL | Discord timecode
guild_id | INT UNSIGNED | NOT NULL | Discord guild ID for referencing `silvanus`.guildInfo
Table: `silvanus`.auto_role_status
id | INT | NOT NULL | AUTO INCREMENT | PRIMARY KEY
user_id | INT UNSIGNED | NOT NULL
guild_id | INT UNSIGNED | NOT NULL
status | VARCHAR(10) | NOT NULL | DEFAULT "REMOVED" | OPTION: {"REMOVED", "ADDED"}

View File

@ -28,7 +28,7 @@ const fn = require('./modules/functions.js');
const strings = require('./data/strings.json'); const strings = require('./data/strings.json');
const dbfn = require('./modules/dbfn.js'); const dbfn = require('./modules/dbfn.js');
const { GuildInfo } = require('./modules/CustomClasses.js'); const { GuildInfo } = require('./modules/CustomClasses.js');
const isDev = process.env.DEBUG; const isDev = process.env.DEBUG === "true";
let statusChannel; let statusChannel;
client.once('ready', async () => { client.once('ready', async () => {
@ -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

@ -1145,13 +1145,14 @@ const functions = {
return errorId; return errorId;
}, },
async sendHeartbeat(url) { async sendHeartbeat(url) {
console.log(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");
}); });

View File

@ -1,6 +1,6 @@
{ {
"name": "silvanus", "name": "silvanus",
"version": "1.2.7", "version": "1.2.8",
"description": "Grow A Tree Companion Bot", "description": "Grow A Tree Companion Bot",
"main": "main.js", "main": "main.js",
"scripts": { "scripts": {