mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
- Updated the scheduleRouter to manage job scheduling and removal based on the enabled status of schedules, improving job lifecycle management. - Refactored the scheduleJob and removeJob utilities to support scheduling and removing jobs for both server and schedule types. - Introduced a new schema for jobQueue to accommodate schedule jobs, enhancing the flexibility of job definitions. - Improved the runJobs function to execute scheduled jobs based on their enabled status, ensuring proper execution of active schedules. - Enhanced the initialization process for schedules to automatically schedule active jobs from the database, streamlining the setup process.
22 lines
445 B
TypeScript
22 lines
445 B
TypeScript
import { z } from "zod";
|
|
|
|
export const jobQueueSchema = z.discriminatedUnion("type", [
|
|
z.object({
|
|
cronSchedule: z.string(),
|
|
type: z.literal("backup"),
|
|
backupId: z.string(),
|
|
}),
|
|
z.object({
|
|
cronSchedule: z.string(),
|
|
type: z.literal("server"),
|
|
serverId: z.string(),
|
|
}),
|
|
z.object({
|
|
cronSchedule: z.string(),
|
|
type: z.literal("schedule"),
|
|
scheduleId: z.string(),
|
|
}),
|
|
]);
|
|
|
|
export type QueueJob = z.infer<typeof jobQueueSchema>;
|