* 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
28 lines
847 B
TypeScript
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() };
|
|
}
|
|
}
|