fix: remove cron jobs after delete service

This commit is contained in:
Mauricio Siu
2025-01-26 18:59:27 -06:00
parent 1e56364f93
commit 0fb67ced5d
8 changed files with 72 additions and 8 deletions

View File

@@ -1,3 +1,10 @@
import {
type BackupScheduleList,
IS_CLOUD,
removeScheduleBackup,
scheduleBackup,
} from "@dokploy/server/index";
type QueueJob =
| {
type: "backup";
@@ -59,3 +66,19 @@ export const updateJob = async (job: QueueJob) => {
throw error;
}
};
export const cancelJobs = async (backups: BackupScheduleList) => {
for (const backup of backups) {
if (backup.enabled) {
if (IS_CLOUD) {
await removeJob({
cronSchedule: backup.schedule,
backupId: backup.backupId,
type: "backup",
});
} else {
removeScheduleBackup(backup.backupId);
}
}
}
};