zerobyte/app/server/jobs/healthchecks.ts
Nico 35773a6969
refactor: upgrade to drizzle v1 (#450)
* refactor: move migrations to new structure

* refactor: convert all findMany to new structure

* fix(backups-schedule): missing null matching for last backup status

* chore: move root lib to server
2026-02-01 19:14:52 +01:00

28 lines
847 B
TypeScript

import { Job } from "../core/scheduler";
import { volumeService } from "../modules/volumes/volume.service";
import { logger } from "../utils/logger";
import { db } from "../db/db";
import { withContext } from "../core/request-context";
export class VolumeHealthCheckJob extends Job {
async run() {
logger.debug("Running health check for all volumes...");
const volumes = await db.query.volumesTable.findMany({
where: {
OR: [{ status: "mounted" }, { status: "error" }],
},
});
for (const volume of volumes) {
await withContext({ organizationId: volume.organizationId }, async () => {
const { status } = await volumeService.checkHealth(volume.id);
if (status === "error" && volume.autoRemount) {
await volumeService.mountVolume(volume.id);
}
});
}
return { done: true, timestamp: new Date() };
}
}