feat(api): enhance health check and DNS management
quality / commitlint (push) Skipped
CD / update-wiki (push) Successful in 7s
quality / changes (push) Successful in 8s
quality / docker-check (push) Skipped
quality / web (push) Successful in 1m9s
quality / api (push) Successful in 40s
CD / quality (push) Successful in 2m0s
CD / publish (push) Successful in 2m38s
quality / commitlint (push) Skipped
CD / update-wiki (push) Successful in 7s
quality / changes (push) Successful in 8s
quality / docker-check (push) Skipped
quality / web (push) Successful in 1m9s
quality / api (push) Successful in 40s
CD / quality (push) Successful in 2m0s
CD / publish (push) Successful in 2m38s
- Added batch endpoint for health status queries to reduce the number of requests. - Improved DNS record management with caching and invalidation mechanisms. - Updated health check service to handle new configurations and improve performance. - Refactored certificate service to utilize concurrency for checks, enhancing efficiency. - Removed unused dependencies and optimized package configurations. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
+13
-3
@@ -32,6 +32,7 @@ import {
|
||||
import { settingsRoutes } from "./routes/settings.js";
|
||||
import { integrationsVpsTrackerRoutes } from "./routes/integrations-vps-tracker.js";
|
||||
import { auditRoutes } from "./routes/audit.js";
|
||||
import { repos, walCheckpointTruncate } from "@cfdm/db";
|
||||
import * as certificateService from "./services/certificate-service.js";
|
||||
import {
|
||||
createHealthCheckTask,
|
||||
@@ -43,7 +44,7 @@ import {
|
||||
scheduleWeightedDnsJob,
|
||||
} from "./services/weighted-dns-scheduler.js";
|
||||
import { fireEnsureHealthWorker } from "./services/health/health-worker-deploy.js";
|
||||
import { AsyncTask, CronJob } from "toad-scheduler";
|
||||
import { AsyncTask, CronJob, ToadScheduler } from "toad-scheduler";
|
||||
|
||||
export interface BuildAppOptions {
|
||||
config?: AppConfig;
|
||||
@@ -111,11 +112,20 @@ export async function buildApp(opts: BuildAppOptions = {}) {
|
||||
}
|
||||
|
||||
if (!opts.memory) {
|
||||
await app.register(import("@fastify/schedule"));
|
||||
const scheduler = new ToadScheduler();
|
||||
app.decorate("scheduler", scheduler);
|
||||
app.addHook("onClose", async () => {
|
||||
scheduler.stop();
|
||||
});
|
||||
|
||||
const certTask = new AsyncTask(
|
||||
"certificate-check",
|
||||
async () => {
|
||||
const pruned = repos.pruneLogs(app.db);
|
||||
if (pruned > 0) {
|
||||
app.log.info({ pruned }, "log retention pruned");
|
||||
}
|
||||
walCheckpointTruncate(app.sqlite);
|
||||
const n = await certificateService.runAllChecks(app.db);
|
||||
app.log.info({ checked: n }, "certificate check completed");
|
||||
},
|
||||
@@ -124,7 +134,7 @@ export async function buildApp(opts: BuildAppOptions = {}) {
|
||||
},
|
||||
);
|
||||
|
||||
app.scheduler.addCronJob(
|
||||
scheduler.addCronJob(
|
||||
new CronJob(
|
||||
{ cronExpression: config.certCheckCron },
|
||||
certTask,
|
||||
|
||||
Reference in New Issue
Block a user