Linked Rabbiteer & Crons

This commit is contained in:
Dunemask 2022-05-05 20:30:24 +00:00
parent 0ce2785b75
commit 8b136eb565
8 changed files with 58 additions and 8 deletions

View file

@ -1,14 +1,13 @@
import "dotenv/config"; // Load Envars
// Imports // Imports
import fig from "figlet"; import fig from "figlet";
import http from "http"; import http from "http";
import { INFO, OK, logInfo } from "../util/logging.js"; import { INFO, OK, logInfo } from "../util/logging.js";
// import "../utils/preload.js"; // Load Globals
// Import Core Modules // Import Core Modules
import expressApp from "./server.js";
import applySockets from "../sockets/handler.js"; import applySockets from "../sockets/handler.js";
import JobManager from "./JobManager.js"; import JobManager from "./JobManager.js";
import rabbiteer from "../rabbit/rabbit-workers.js";
// Constants // Constants
const title = "QLTR"; const title = "QLTR";
@ -25,9 +24,10 @@ export default class Qualiteer {
async _preinitialize() { async _preinitialize() {
logInfo(fig.textSync(title, "Cosmike")); logInfo(fig.textSync(title, "Cosmike"));
INFO("INIT", "Initializing..."); INFO("INIT", "Initializing...");
this.app = (await import("./server.js")).default; this.app = expressApp;
this.server = http.createServer(this.app); this.server = http.createServer(this.app);
this.sockets = applySockets(this.server, this.jobs); this.sockets = applySockets(this.server, this.jobs);
this.rabbiteer = rabbiteer;
} }
start() { start() {

13
lib/core/crons.js Normal file
View file

@ -0,0 +1,13 @@
import cron from "cron";
const { CronJob } = cron;
// Remove Expired Silenced Tests
const expiredSilenced = () => {
console.log("Would Update Silenced Tests");
};
const silencedCron = new CronJob("* * * * * *", expiredSilenced);
export default async function startCrons() {
silencedCron.start();
}

View file

@ -11,3 +11,5 @@ app.all("/", (req, res) => res.redirect("/qualiteer"));
// Routes // Routes
app.use("/api/results", results); app.use("/api/results", results);
export default app;

View file

@ -0,0 +1,14 @@
import Rabbiteer from "rabbiteer";
import workers from "./workers/index.js";
// Pull Environment Variables
const { RABBIT_HOST: host, RABBIT_USER: user, RABBIT_PASS: pass } = process.env;
// Rabbit Config
const rabbitConfig = {
host: host ?? "localhost",
user: user ?? "rabbit",
pass: pass ?? "rabbit",
};
export default new Rabbiteer(null, workers, { autoRabbit: rabbitConfig });

View file

@ -1,7 +1,7 @@
// Imports // Imports
import { RabbitConsumer } from "rabiteer"; import { Worker } from "rabbiteer";
// Class // Class
export default class TestResultsConsumer extends RabbitConsumer { export default class TestResultsWorker extends Worker {
constructor() { constructor() {
super("TestResults"); super("TestResults");
} }

View file

@ -0,0 +1,3 @@
import TestResultsWorker from "./TestResultsWorker.js";
export default [new TestResultsWorker()];

20
package-lock.json generated
View file

@ -18,6 +18,7 @@
"moment": "^2.29.3", "moment": "^2.29.3",
"pg-promise": "^10.11.1", "pg-promise": "^10.11.1",
"postgres-migrations": "^5.3.0", "postgres-migrations": "^5.3.0",
"rabbiteer": "gitlab:Dunemask/rabbiteer",
"socket.io": "^4.4.1", "socket.io": "^4.4.1",
"socket.io-client": "^4.4.1", "socket.io-client": "^4.4.1",
"uuid": "^8.3.2" "uuid": "^8.3.2"
@ -37,7 +38,7 @@
"readline-sync": "^1.4.10" "readline-sync": "^1.4.10"
}, },
"optionalDependencies": { "optionalDependencies": {
"rabbiteer": "^1.0.0" "rabbiteer": "gitlab:Dunemask/rabbiteer"
} }
}, },
"node_modules/@ampproject/remapping": { "node_modules/@ampproject/remapping": {
@ -14590,6 +14591,15 @@
"url": "https://github.com/sponsors/sindresorhus" "url": "https://github.com/sponsors/sindresorhus"
} }
}, },
"node_modules/rabbiteer": {
"version": "1.0.0",
"resolved": "git+ssh://git@gitlab.com/Dunemask/rabbiteer.git#6bb6cc26ca7ea7f4eb934529305ebb8ae0b26369",
"license": "LGPL-2.1-only",
"optional": true,
"dependencies": {
"amqplib": "^0.8.0"
}
},
"node_modules/raf": { "node_modules/raf": {
"version": "3.4.1", "version": "3.4.1",
"resolved": "https://registry.npmjs.org/raf/-/raf-3.4.1.tgz", "resolved": "https://registry.npmjs.org/raf/-/raf-3.4.1.tgz",
@ -28751,6 +28761,14 @@
"integrity": "sha512-WuyALRjWPDGtt/wzJiadO5AXY+8hZ80hVpe6MyivgraREW751X3SbhRvG3eLKOYN+8VEvqLcf3wdnt44Z4S4SA==", "integrity": "sha512-WuyALRjWPDGtt/wzJiadO5AXY+8hZ80hVpe6MyivgraREW751X3SbhRvG3eLKOYN+8VEvqLcf3wdnt44Z4S4SA==",
"dev": true "dev": true
}, },
"rabbiteer": {
"version": "git+ssh://git@gitlab.com/Dunemask/rabbiteer.git#6bb6cc26ca7ea7f4eb934529305ebb8ae0b26369",
"from": "rabbiteer@git+https://gitlab.com/Dunemask/rabbiteer.git",
"optional": true,
"requires": {
"amqplib": "^0.8.0"
}
},
"raf": { "raf": {
"version": "3.4.1", "version": "3.4.1",
"resolved": "https://registry.npmjs.org/raf/-/raf-3.4.1.tgz", "resolved": "https://registry.npmjs.org/raf/-/raf-3.4.1.tgz",

View file

@ -24,7 +24,7 @@
"author": "Dunemask", "author": "Dunemask",
"license": "LGPL-2.1-only", "license": "LGPL-2.1-only",
"optionalDependencies": { "optionalDependencies": {
"rabbiteer": "^1.0.0" "rabbiteer": "gitlab:Dunemask/rabbiteer"
}, },
"dependencies": { "dependencies": {
"@mui/icons-material": "^5.6.2", "@mui/icons-material": "^5.6.2",