mirror of
https://github.com/andwati/dokploy.git
synced 2026-10-18 03:02:56 +00:00
feat(schedules): replace hardcoded cron schedule with CLEANUP_CRON_JOB constant
- Updated the cron schedule for Docker cleanup tasks across multiple files to use the new CLEANUP_CRON_JOB constant. - This change enhances maintainability by centralizing the cron schedule configuration, ensuring consistency across the application.
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import {
|
import {
|
||||||
|
CLEANUP_CRON_JOB,
|
||||||
canAccessToTraefikFiles,
|
canAccessToTraefikFiles,
|
||||||
checkGPUStatus,
|
checkGPUStatus,
|
||||||
checkPortInUse,
|
checkPortInUse,
|
||||||
@@ -298,12 +299,12 @@ export const settingsRouter = createTRPCRouter({
|
|||||||
}
|
}
|
||||||
if (IS_CLOUD) {
|
if (IS_CLOUD) {
|
||||||
await schedule({
|
await schedule({
|
||||||
cronSchedule: "0 0 * * *",
|
cronSchedule: CLEANUP_CRON_JOB,
|
||||||
serverId: input.serverId,
|
serverId: input.serverId,
|
||||||
type: "server",
|
type: "server",
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
scheduleJob(server.serverId, "0 0 * * *", async () => {
|
scheduleJob(server.serverId, CLEANUP_CRON_JOB, async () => {
|
||||||
console.log(
|
console.log(
|
||||||
`Docker Cleanup ${new Date().toLocaleString()}] Running...`,
|
`Docker Cleanup ${new Date().toLocaleString()}] Running...`,
|
||||||
);
|
);
|
||||||
@@ -316,7 +317,7 @@ export const settingsRouter = createTRPCRouter({
|
|||||||
} else {
|
} else {
|
||||||
if (IS_CLOUD) {
|
if (IS_CLOUD) {
|
||||||
await removeJob({
|
await removeJob({
|
||||||
cronSchedule: "0 0 * * *",
|
cronSchedule: CLEANUP_CRON_JOB,
|
||||||
serverId: input.serverId,
|
serverId: input.serverId,
|
||||||
type: "server",
|
type: "server",
|
||||||
});
|
});
|
||||||
@@ -331,7 +332,7 @@ export const settingsRouter = createTRPCRouter({
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (settingsUpdated?.enableDockerCleanup) {
|
if (settingsUpdated?.enableDockerCleanup) {
|
||||||
scheduleJob("docker-cleanup", "0 0 * * *", async () => {
|
scheduleJob("docker-cleanup", CLEANUP_CRON_JOB, async () => {
|
||||||
console.log(
|
console.log(
|
||||||
`Docker Cleanup ${new Date().toLocaleString()}] Running...`,
|
`Docker Cleanup ${new Date().toLocaleString()}] Running...`,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import {
|
import {
|
||||||
|
CLEANUP_CRON_JOB,
|
||||||
cleanupAll,
|
cleanupAll,
|
||||||
findBackupById,
|
findBackupById,
|
||||||
findScheduleById,
|
findScheduleById,
|
||||||
@@ -125,7 +126,7 @@ export const initializeJobs = async () => {
|
|||||||
scheduleJob({
|
scheduleJob({
|
||||||
serverId,
|
serverId,
|
||||||
type: "server",
|
type: "server",
|
||||||
cronSchedule: "0 0 * * *",
|
cronSchedule: CLEANUP_CRON_JOB,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import path from "node:path";
|
|||||||
import Docker from "dockerode";
|
import Docker from "dockerode";
|
||||||
|
|
||||||
export const IS_CLOUD = process.env.IS_CLOUD === "true";
|
export const IS_CLOUD = process.env.IS_CLOUD === "true";
|
||||||
|
export const CLEANUP_CRON_JOB = "50 23 * * *";
|
||||||
export const docker = new Docker();
|
export const docker = new Docker();
|
||||||
|
|
||||||
export const BETTER_AUTH_SECRET =
|
export const BETTER_AUTH_SECRET =
|
||||||
@@ -29,5 +30,6 @@ export const paths = (isServer = false) => {
|
|||||||
REGISTRY_PATH: `${BASE_PATH}/registry`,
|
REGISTRY_PATH: `${BASE_PATH}/registry`,
|
||||||
SCHEDULES_PATH: `${BASE_PATH}/schedules`,
|
SCHEDULES_PATH: `${BASE_PATH}/schedules`,
|
||||||
VOLUME_BACKUPS_PATH: `${BASE_PATH}/volume-backups`,
|
VOLUME_BACKUPS_PATH: `${BASE_PATH}/volume-backups`,
|
||||||
|
VOLUME_BACKUP_LOCK_PATH: `${BASE_PATH}/volume-backup-lock`,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
|
import { CLEANUP_CRON_JOB } from "@dokploy/server/constants";
|
||||||
import { member } from "@dokploy/server/db/schema";
|
import { member } from "@dokploy/server/db/schema";
|
||||||
import type { BackupSchedule } from "@dokploy/server/services/backup";
|
import type { BackupSchedule } from "@dokploy/server/services/backup";
|
||||||
import { getAllServers } from "@dokploy/server/services/server";
|
import { getAllServers } from "@dokploy/server/services/server";
|
||||||
@@ -29,7 +30,7 @@ export const initCronJobs = async () => {
|
|||||||
const webServerSettings = await getWebServerSettings();
|
const webServerSettings = await getWebServerSettings();
|
||||||
|
|
||||||
if (webServerSettings?.enableDockerCleanup) {
|
if (webServerSettings?.enableDockerCleanup) {
|
||||||
scheduleJob("docker-cleanup", "0 0 * * *", async () => {
|
scheduleJob("docker-cleanup", CLEANUP_CRON_JOB, async () => {
|
||||||
console.log(
|
console.log(
|
||||||
`Docker Cleanup ${new Date().toLocaleString()}] Running docker cleanup`,
|
`Docker Cleanup ${new Date().toLocaleString()}] Running docker cleanup`,
|
||||||
);
|
);
|
||||||
@@ -45,7 +46,7 @@ export const initCronJobs = async () => {
|
|||||||
for (const server of servers) {
|
for (const server of servers) {
|
||||||
const { serverId, enableDockerCleanup, name } = server;
|
const { serverId, enableDockerCleanup, name } = server;
|
||||||
if (enableDockerCleanup) {
|
if (enableDockerCleanup) {
|
||||||
scheduleJob(serverId, "0 0 * * *", async () => {
|
scheduleJob(serverId, CLEANUP_CRON_JOB, async () => {
|
||||||
console.log(
|
console.log(
|
||||||
`SERVER-BACKUP[${new Date().toLocaleString()}] Running Cleanup ${name}`,
|
`SERVER-BACKUP[${new Date().toLocaleString()}] Running Cleanup ${name}`,
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user