mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-06-15 20:25:23 +02:00
fix(schedules): ensure cronSchedule is always a string when removing jobs
- Updated the job removal logic to default cronSchedule to an empty string if job.pattern is undefined, preventing potential errors during job removal.
This commit is contained in:
@@ -47,25 +47,25 @@ app.post("/update-backup", zValidator("json", jobQueueSchema), async (c) => {
|
||||
result = await removeJob({
|
||||
backupId: data.backupId,
|
||||
type: "backup",
|
||||
cronSchedule: job.pattern,
|
||||
cronSchedule: job.pattern || "",
|
||||
});
|
||||
} else if (data.type === "server") {
|
||||
result = await removeJob({
|
||||
serverId: data.serverId,
|
||||
type: "server",
|
||||
cronSchedule: job.pattern,
|
||||
cronSchedule: job.pattern || "",
|
||||
});
|
||||
} else if (data.type === "schedule") {
|
||||
result = await removeJob({
|
||||
scheduleId: data.scheduleId,
|
||||
type: "schedule",
|
||||
cronSchedule: job.pattern,
|
||||
cronSchedule: job.pattern || "",
|
||||
});
|
||||
} else if (data.type === "volume-backup") {
|
||||
result = await removeJob({
|
||||
volumeBackupId: data.volumeBackupId,
|
||||
type: "volume-backup",
|
||||
cronSchedule: job.pattern,
|
||||
cronSchedule: job.pattern || "",
|
||||
});
|
||||
}
|
||||
logger.info({ result }, "Job removed");
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
import { Queue, type RepeatableJob } from "bullmq";
|
||||
import IORedis from "ioredis";
|
||||
import { logger } from "./logger.js";
|
||||
import type { QueueJob } from "./schema.js";
|
||||
|
||||
export const connection = new IORedis(process.env.REDIS_URL!, {
|
||||
maxRetriesPerRequest: null,
|
||||
});
|
||||
export const jobQueue = new Queue("backupQueue", {
|
||||
connection,
|
||||
connection: {
|
||||
url: process.env.REDIS_URL!,
|
||||
},
|
||||
defaultJobOptions: {
|
||||
removeOnComplete: true,
|
||||
removeOnFail: true,
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { type Job, Worker } from "bullmq";
|
||||
import { logger } from "./logger.js";
|
||||
import { connection } from "./queue.js";
|
||||
import type { QueueJob } from "./schema.js";
|
||||
import { runJobs } from "./utils.js";
|
||||
|
||||
@@ -12,7 +11,9 @@ export const firstWorker = new Worker(
|
||||
},
|
||||
{
|
||||
concurrency: 100,
|
||||
connection,
|
||||
connection: {
|
||||
url: process.env.REDIS_URL!,
|
||||
},
|
||||
},
|
||||
);
|
||||
export const secondWorker = new Worker(
|
||||
@@ -23,7 +24,9 @@ export const secondWorker = new Worker(
|
||||
},
|
||||
{
|
||||
concurrency: 100,
|
||||
connection,
|
||||
connection: {
|
||||
url: process.env.REDIS_URL!,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
@@ -35,6 +38,8 @@ export const thirdWorker = new Worker(
|
||||
},
|
||||
{
|
||||
concurrency: 100,
|
||||
connection,
|
||||
connection: {
|
||||
url: process.env.REDIS_URL!,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user