* refactor: extract restic in core package * chore: add turbo task runner * refactor: split server utils * chore: simplify withDeps signature and fix non-null assertion
27 lines
902 B
TypeScript
27 lines
902 B
TypeScript
import { Job } from "../core/scheduler";
|
|
import { repositoriesService } from "../modules/repositories/repositories.service";
|
|
import { logger } from "@zerobyte/core/node";
|
|
import { db } from "../db/db";
|
|
import { withContext } from "../core/request-context";
|
|
|
|
export class RepositoryHealthCheckJob extends Job {
|
|
async run() {
|
|
logger.debug("Running health check for all repositories...");
|
|
|
|
const repositories = await db.query.repositoriesTable.findMany({
|
|
where: { OR: [{ status: "healthy" }, { status: "error" }] },
|
|
});
|
|
|
|
for (const repository of repositories) {
|
|
try {
|
|
await withContext({ organizationId: repository.organizationId }, async () => {
|
|
await repositoriesService.checkHealth(repository.shortId);
|
|
});
|
|
} catch (error) {
|
|
logger.error(`Health check failed for repository ${repository.name}:`, error);
|
|
}
|
|
}
|
|
|
|
return { done: true, timestamp: new Date() };
|
|
}
|
|
}
|