refactor(db): added in notifications vs pulling from the db makes it easier on the system

This commit is contained in:
2026-06-10 16:26:21 -05:00
parent 9440b44f3b
commit 706ab8b448
6 changed files with 229 additions and 1 deletions

View File

@@ -2,6 +2,8 @@ import { createServer } from "node:http";
import os from "node:os";
import createApp from "./app.js";
import { db } from "./db/db.controller.js";
import { startDbNotificationListener } from "./db/db.listener.js";
import { setupDbNotifications } from "./db/db.setupNotifications.js";
import { dbCleanup } from "./db/dbCleanup.controller.js";
import { type Setting, settings } from "./db/schema/settings.schema.js";
import { connectGPSql } from "./gpSql/gpSqlConnection.controller.js";
@@ -43,12 +45,13 @@ const start = async () => {
startTCPServer();
connectProdSql();
connectGPSql();
startDbNotificationListener();
// trigger startup processes these must run before anything else can run
await baseSettingValidationCheck();
systemSettings = await db.select().from(settings);
//when starting up long lived features the name must match the setting name.
// when starting up long lived features the name must match the setting name.
// also we always want to have long lived processes inside a setting check.
setTimeout(() => {
if (systemSettings.filter((n) => n.name === "opendock_sync")[0]?.active) {
@@ -89,6 +92,7 @@ const start = async () => {
startNotifications();
serversChecks();
aggregateRouteHitsForBusinessDay();
setupDbNotifications();
// can be removed at a later date
sqlJobCleanUp();