mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-07-10 00:15:28 +02:00
feat(schedules): add schedules server
This commit is contained in:
46
apps/dokploy/server/utils/backup.ts
Normal file
46
apps/dokploy/server/utils/backup.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
type QueueJob =
|
||||
| {
|
||||
type: "backup";
|
||||
cronSchedule: string;
|
||||
backupId: string;
|
||||
}
|
||||
| {
|
||||
type: "server";
|
||||
cronSchedule: string;
|
||||
serverId: 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",
|
||||
},
|
||||
body: JSON.stringify(job),
|
||||
});
|
||||
const data = await result.json();
|
||||
console.log(data);
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
export const removeJob = async (job: QueueJob) => {
|
||||
try {
|
||||
const result = await fetch(`${process.env.JOBS_URL}/remove-job`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(job),
|
||||
});
|
||||
const data = await result.json();
|
||||
console.log(data);
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user