mirror of
https://github.com/nicotsx/ironmount.git
synced 2025-12-10 12:10:51 +01:00
* refactor: unify backend and frontend servers * refactor: correct paths for openapi & drizzle * refactor: move api-client to client * fix: drizzle paths * chore: fix linting issues * fix: form reset issue
26 lines
802 B
TypeScript
26 lines
802 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 { eq, or } from "drizzle-orm";
|
|
import { volumesTable } from "../db/schema";
|
|
|
|
export class VolumeHealthCheckJob extends Job {
|
|
async run() {
|
|
logger.debug("Running health check for all volumes...");
|
|
|
|
const volumes = await db.query.volumesTable.findMany({
|
|
where: or(eq(volumesTable.status, "mounted"), eq(volumesTable.status, "error")),
|
|
});
|
|
|
|
for (const volume of volumes) {
|
|
const { status } = await volumeService.checkHealth(volume.name);
|
|
if (status === "error" && volume.autoRemount) {
|
|
await volumeService.mountVolume(volume.name);
|
|
}
|
|
}
|
|
|
|
return { done: true, timestamp: new Date() };
|
|
}
|
|
}
|