mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-09-14 11:06:15 +05:00
Merge pull request #5245 from Dokploy/fix/schedule-cloud-update-orphan-job
fix: orphaned BullMQ job when updating an enabled schedule in cloud
This commit is contained in:
commit
48e0b747b6
@ -25,7 +25,7 @@ import { asc, desc, eq } from "drizzle-orm";
|
||||
import { z } from "zod";
|
||||
import { audit } from "@/server/api/utils/audit";
|
||||
import { assertScheduledJobLimit } from "@/server/api/utils/plan-limits";
|
||||
import { removeJob, schedule } from "@/server/utils/backup";
|
||||
import { removeJob, schedule, updateJob } from "@/server/utils/backup";
|
||||
import { createTRPCRouter, protectedProcedure } from "../trpc";
|
||||
|
||||
export const scheduleRouter = createTRPCRouter({
|
||||
@ -130,7 +130,7 @@ export const scheduleRouter = createTRPCRouter({
|
||||
|
||||
if (IS_CLOUD) {
|
||||
if (updatedSchedule?.enabled) {
|
||||
schedule({
|
||||
await updateJob({
|
||||
scheduleId: updatedSchedule.scheduleId,
|
||||
type: "schedule",
|
||||
cronSchedule: updatedSchedule.cronExpression,
|
||||
@ -141,6 +141,7 @@ export const scheduleRouter = createTRPCRouter({
|
||||
cronSchedule: updatedSchedule.cronExpression,
|
||||
scheduleId: updatedSchedule.scheduleId,
|
||||
type: "schedule",
|
||||
timezone: updatedSchedule.timezone,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
@ -185,6 +186,7 @@ export const scheduleRouter = createTRPCRouter({
|
||||
cronSchedule: scheduleItem.cronExpression,
|
||||
scheduleId: scheduleItem.scheduleId,
|
||||
type: "schedule",
|
||||
timezone: scheduleItem.timezone,
|
||||
});
|
||||
} else {
|
||||
removeScheduleJob(scheduleItem.scheduleId);
|
||||
|
||||
@ -60,6 +60,7 @@ app.post("/update-backup", zValidator("json", jobQueueSchema), async (c) => {
|
||||
scheduleId: data.scheduleId,
|
||||
type: "schedule",
|
||||
cronSchedule: job.pattern || "",
|
||||
timezone: job.tz || data.timezone,
|
||||
});
|
||||
} else if (data.type === "volume-backup") {
|
||||
result = await removeJob({
|
||||
|
||||
@ -66,9 +66,10 @@ export const removeJob = async (data: QueueJob) => {
|
||||
return result;
|
||||
}
|
||||
if (data.type === "schedule") {
|
||||
const { scheduleId, cronSchedule } = data;
|
||||
const { scheduleId, cronSchedule, timezone } = data;
|
||||
const result = await jobQueue.removeRepeatable(scheduleId, {
|
||||
pattern: cronSchedule,
|
||||
tz: timezone || "UTC",
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user