Implement Node Monitor Service

- Check in with online nodes every n ms
- Update nodes that do not reply
- Added node object record helper
- Updated mysql wrapper for updating node info to accept bool or number
This commit is contained in:
Logan Cusano
2023-05-07 02:41:58 -04:00
parent 7b2215e9da
commit 9b2d0c4bbb
5 changed files with 141 additions and 51 deletions

View File

@@ -1,20 +1,21 @@
// Modules
var createError = require('http-errors');
var express = require('express');
var path = require('path');
var cookieParser = require('cookie-parser');
var logger = require('morgan');
var http = require('http');
const fs = require('fs');
require('dotenv').config();
// Utilities
const { RSSController } = require("./controllers/rssController");
const libUtils = require("./libUtils");
const deployCommands = require("./utilities/deployCommands");
const { nodeMonitorService } = require('./controllers/nodesController');
// Debug
const { DebugBuilder } = require("./utilities/debugBuilder");
const log = new DebugBuilder("server", "index");
//const Discord = require('discord.js');Client, Collection, Intents
const {
Client,
Events,
@@ -23,7 +24,6 @@ const {
MessageActionRow,
MessageButton
} = require('discord.js');
//const client = new Discord.Client();
const client = new Client({
intents: [GatewayIntentBits.GuildMessages, GatewayIntentBits.Guilds]
@@ -92,6 +92,14 @@ async function runHTTPServer() {
})
}
/**
* Start the node monitoring service
*/
async function runNodeMonitorService(){
const monitor = new nodeMonitorService();
monitor.start();
}
/**
* Start the RSS background process
*/
@@ -128,6 +136,9 @@ client.on('ready', () => {
log.DEBUG(`Starting HTTP Server`);
runHTTPServer();
log.DEBUG("Starting Node Monitoring Service");
runNodeMonitorService();
log.DEBUG("Starting RSS watcher");
runRssService();
});