correction to monitor opendock activation

This commit is contained in:
2026-03-11 16:23:04 -05:00
parent 4f24fe4660
commit bf7d765989
5 changed files with 41 additions and 14 deletions

View File

@@ -1,7 +1,9 @@
import { createServer } from "node:http";
import os from "node:os";
import createApp from "./app.js";
import { db } from "./db/db.controller.js";
import { dbCleanup } from "./db/dbCleanup.controller.js";
import { type Setting, settings } from "./db/schema/settings.schema.js";
import { createLogger } from "./logger/logger.controller.js";
import { monitorReleaseChanges } from "./opendock/openDockRreleaseMonitor.utils.js";
import { opendockSocketMonitor } from "./opendock/opendockSocketMonitor.utils.js";
@@ -11,7 +13,7 @@ import { baseSettingValidationCheck } from "./system/settingsBase.controller.js"
import { createCronJob } from "./utils/croner.utils.js";
const port = Number(process.env.PORT) || 3000;
export let systemSettings: Setting[] = [];
const start = async () => {
const log = createLogger({ module: "system", subModule: "main start" });
@@ -20,20 +22,24 @@ const start = async () => {
// 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.
setTimeout(() => {
monitorReleaseChanges(); // this is od monitoring the db for all new releases
opendockSocketMonitor();
if (systemSettings.filter((n) => n.name === "opendock_sync")[0]?.active) {
log.info({}, "Opendock is not active");
monitorReleaseChanges(); // this is od monitoring the db for all new releases
opendockSocketMonitor();
createCronJob("opendockAptCleanup", "0 30 5 * * *", () =>
dbCleanup("opendockApt", 90),
);
}
// cleanup sql jobs
createCronJob("JobAuditLogCleanUp", "0 0 5 * * *", () =>
dbCleanup("jobs", 30),
);
createCronJob("logsCleanup", "0 15 5 * * *", () => dbCleanup("logs", 120));
createCronJob("opendockAptCleanup", "0 30 5 * * *", () =>
dbCleanup("opendockApt", 90),
);
}, 5 * 1000);
const { app, baseUrl } = await createApp();