mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
Enhance schedule management and job handling features
- 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.
This commit is contained in:
@@ -34,8 +34,8 @@ app.use(async (c, next) => {
|
||||
app.post("/create-backup", zValidator("json", jobQueueSchema), async (c) => {
|
||||
const data = c.req.valid("json");
|
||||
scheduleJob(data);
|
||||
logger.info({ data }, "Backup created successfully");
|
||||
return c.json({ message: "Backup created successfully" });
|
||||
logger.info({ data }, `[${data.type}] created successfully`);
|
||||
return c.json({ message: `[${data.type}] created successfully` });
|
||||
});
|
||||
|
||||
app.post("/update-backup", zValidator("json", jobQueueSchema), async (c) => {
|
||||
@@ -55,6 +55,12 @@ app.post("/update-backup", zValidator("json", jobQueueSchema), async (c) => {
|
||||
type: "server",
|
||||
cronSchedule: job.pattern,
|
||||
});
|
||||
} else if (data.type === "schedule") {
|
||||
result = await removeJob({
|
||||
scheduleId: data.scheduleId,
|
||||
type: "schedule",
|
||||
cronSchedule: job.pattern,
|
||||
});
|
||||
}
|
||||
logger.info({ result }, "Job removed");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user