mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-10-23 08:55:25 +00:00
Merge pull request #5748 from Dokploy/fix/cloud-schedule-null-timezone
fix: register cloud schedules without a timezone
This commit is contained in:
@@ -267,7 +267,7 @@ export const backupRouter = createTRPCRouter({
|
||||
|
||||
const value = await removeBackupById(input.backupId);
|
||||
if (IS_CLOUD && value) {
|
||||
removeJob({
|
||||
await removeJob({
|
||||
backupId: input.backupId,
|
||||
cronSchedule: value.schedule,
|
||||
type: "backup",
|
||||
|
||||
@@ -66,7 +66,7 @@ export const scheduleRouter = createTRPCRouter({
|
||||
|
||||
if (newSchedule?.enabled) {
|
||||
if (IS_CLOUD) {
|
||||
schedule({
|
||||
await schedule({
|
||||
scheduleId: newSchedule.scheduleId,
|
||||
type: "schedule",
|
||||
cronSchedule: newSchedule.cronExpression,
|
||||
|
||||
@@ -26,56 +26,29 @@ type QueueJob =
|
||||
cronSchedule: string;
|
||||
volumeBackupId: string;
|
||||
};
|
||||
export const schedule = async (job: QueueJob) => {
|
||||
try {
|
||||
const result = await fetch(`${process.env.JOBS_URL}/create-backup`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"X-API-Key": process.env.API_KEY || "NO-DEFINED",
|
||||
},
|
||||
body: JSON.stringify(job),
|
||||
});
|
||||
const data = await result.json();
|
||||
return data;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
const postJob = async (path: string, job: QueueJob) => {
|
||||
const result = await fetch(`${process.env.JOBS_URL}${path}`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"X-API-Key": process.env.API_KEY || "NO-DEFINED",
|
||||
},
|
||||
body: JSON.stringify(job),
|
||||
});
|
||||
const data = await result.json();
|
||||
if (!result.ok) {
|
||||
throw new Error(
|
||||
`Jobs service ${path} failed (${result.status}): ${JSON.stringify(data)}`,
|
||||
);
|
||||
}
|
||||
return data;
|
||||
};
|
||||
|
||||
export const removeJob = async (job: QueueJob) => {
|
||||
try {
|
||||
const result = await fetch(`${process.env.JOBS_URL}/remove-job`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"X-API-Key": process.env.API_KEY || "NO-DEFINED",
|
||||
},
|
||||
body: JSON.stringify(job),
|
||||
});
|
||||
const data = await result.json();
|
||||
return data;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
export const schedule = (job: QueueJob) => postJob("/create-backup", job);
|
||||
|
||||
export const updateJob = async (job: QueueJob) => {
|
||||
try {
|
||||
const result = await fetch(`${process.env.JOBS_URL}/update-backup`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"X-API-Key": process.env.API_KEY || "NO-DEFINED",
|
||||
},
|
||||
body: JSON.stringify(job),
|
||||
});
|
||||
const data = await result.json();
|
||||
return data;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
export const removeJob = (job: QueueJob) => postJob("/remove-job", job);
|
||||
|
||||
export const updateJob = (job: QueueJob) => postJob("/update-backup", job);
|
||||
|
||||
export const cancelJobs = async (backups: BackupScheduleList) => {
|
||||
for (const backup of backups) {
|
||||
|
||||
@@ -15,7 +15,7 @@ export const jobQueueSchema = z.discriminatedUnion("type", [
|
||||
cronSchedule: z.string(),
|
||||
type: z.literal("schedule"),
|
||||
scheduleId: z.string(),
|
||||
timezone: z.string().optional(),
|
||||
timezone: z.string().nullish(),
|
||||
}),
|
||||
z.object({
|
||||
cronSchedule: z.string(),
|
||||
|
||||
Reference in New Issue
Block a user