* refactor(agent): harden local agent volume lifecycle * chore(test): remove un-used variable * refactor(agent): create dedicated jobs for recurring tasks * chore: pr feedbacks * test: add missing fake agent controller
21 lines
695 B
TypeScript
21 lines
695 B
TypeScript
import { logger } from "@zerobyte/core/node";
|
|
import { toMessage } from "@zerobyte/core/utils";
|
|
import { Effect } from "effect";
|
|
import { cleanupDanglingVolumeMountDirectories } from "../volume-host/cleanup";
|
|
import type { AgentJob } from "./types";
|
|
|
|
const VOLUME_CLEANUP_INTERVAL_MS = 60 * 60 * 1000;
|
|
|
|
export const CleanupDanglingVolumeMountsJob: AgentJob = {
|
|
name: "cleanup-dangling-volume-mounts",
|
|
intervalMs: VOLUME_CLEANUP_INTERVAL_MS,
|
|
run: () =>
|
|
Effect.tryPromise({
|
|
try: cleanupDanglingVolumeMountDirectories,
|
|
catch: (error) => error,
|
|
}).pipe(
|
|
Effect.catchAll((error) =>
|
|
Effect.sync(() => logger.warn(`Agent volume cleanup failed: ${toMessage(error)}`)),
|
|
),
|
|
),
|
|
};
|