refactor: cleanup startup code and add cron job

This commit is contained in:
Nicolas Meienberger
2025-09-23 23:01:42 +02:00
parent 5695a8c700
commit db88bb6de2
5 changed files with 64 additions and 95 deletions

View File

@@ -3,6 +3,7 @@ import * as npath from "node:path";
import { BACKEND_STATUS, type BackendConfig } from "@ironmount/schemas";
import type { VolumeBackend } from "../backend";
import { logger } from "../../../utils/logger";
import { toMessage } from "../../../utils/errors";
const mount = async (_config: BackendConfig, path: string) => {
logger.info("Mounting directory volume...");
@@ -27,7 +28,7 @@ const checkHealth = async (path: string) => {
return { status: BACKEND_STATUS.mounted };
} catch (error) {
logger.error("Directory health check failed:", error);
return { status: BACKEND_STATUS.error, error: error instanceof Error ? error.message : String(error) };
return { status: BACKEND_STATUS.error, error: toMessage(error) };
}
};

View File

@@ -8,6 +8,7 @@ import { logger } from "../../../utils/logger";
import { promisify } from "node:util";
import { withTimeout } from "../../../utils/timeout";
import { OPERATION_TIMEOUT } from "../../../core/constants";
import { toMessage } from "../../../utils/errors";
const execFile = promisify(execFileCb);
@@ -121,8 +122,8 @@ const checkHealth = async (path: string) => {
try {
return await withTimeout(run(), OPERATION_TIMEOUT, "NFS health check");
} catch (error) {
logger.error("NFS volume health check failed:", error);
return { status: BACKEND_STATUS.error, error: error instanceof Error ? error.message : String(error) };
logger.error("NFS volume health check failed:", toMessage(error));
return { status: BACKEND_STATUS.error, error: toMessage(error) };
}
};