mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-06-19 22:25:22 +02:00
* fix: add docker cleanup toggle to remote server creation and update forms * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
40 lines
823 B
TypeScript
40 lines
823 B
TypeScript
import {
|
|
CLEANUP_CRON_JOB,
|
|
cleanupAll,
|
|
IS_CLOUD,
|
|
sendDockerCleanupNotifications,
|
|
} from "@dokploy/server";
|
|
import { scheduledJobs, scheduleJob } from "node-schedule";
|
|
import { removeJob, schedule } from "./backup";
|
|
|
|
export const applyDockerCleanupSchedule = async (
|
|
serverId: string,
|
|
organizationId: string,
|
|
enable: boolean,
|
|
) => {
|
|
if (enable) {
|
|
if (IS_CLOUD) {
|
|
await schedule({
|
|
cronSchedule: CLEANUP_CRON_JOB,
|
|
serverId,
|
|
type: "server",
|
|
});
|
|
} else {
|
|
scheduleJob(serverId, CLEANUP_CRON_JOB, async () => {
|
|
await cleanupAll(serverId);
|
|
await sendDockerCleanupNotifications(organizationId);
|
|
});
|
|
}
|
|
} else {
|
|
if (IS_CLOUD) {
|
|
await removeJob({
|
|
cronSchedule: CLEANUP_CRON_JOB,
|
|
serverId,
|
|
type: "server",
|
|
});
|
|
} else {
|
|
scheduledJobs[serverId]?.cancel();
|
|
}
|
|
}
|
|
};
|