diff --git a/apps/dokploy/components/dashboard/settings/servers/setup-monitoring.tsx b/apps/dokploy/components/dashboard/settings/servers/setup-monitoring.tsx index 9a4ab0507..e14dfbf0e 100644 --- a/apps/dokploy/components/dashboard/settings/servers/setup-monitoring.tsx +++ b/apps/dokploy/components/dashboard/settings/servers/setup-monitoring.tsx @@ -134,11 +134,7 @@ export const SetupMonitoring = ({ serverId }: Props) => { ...(!form.watch("excludedServices")?.includes("*") ? ["*"] : []), ]; - const { mutateAsync } = api.server.setupMonitoring.useMutation({ - onSuccess: () => { - toast.success("Server updated successfully"); - }, - }); + const { mutateAsync } = api.server.setupMonitoring.useMutation(); const onSubmit = async (values: Schema) => { await mutateAsync({ diff --git a/apps/monitoring/src/containers/index.ts b/apps/monitoring/src/containers/index.ts index 1c3015fcf..bee910aba 100644 --- a/apps/monitoring/src/containers/index.ts +++ b/apps/monitoring/src/containers/index.ts @@ -61,17 +61,19 @@ export const logContainerMetrics = () => { const { maxFileSizeMB = 10 } = containerConfig; - const stats = await fs.promises.stat(containerPath); - const fileSizeInMB = stats.size / (1024 * 1024); - - console.log(fileSizeInMB); - if (fileSizeInMB >= maxFileSizeMB) { - const fileContent = fs.readFileSync(containerPath, "utf-8"); - const lines = fileContent.split("\n").filter((line) => line.trim()); - - const linesToKeep = Math.floor(lines.length / 2); - const newContent = `${lines.slice(-linesToKeep).join("\n")}\n`; - fs.writeFileSync(containerPath, newContent); + if (fs.existsSync(containerPath)) { + const stats = await fs.promises.stat(containerPath); + const fileSizeInMB = stats.size / (1024 * 1024); + if (fileSizeInMB >= maxFileSizeMB) { + const fileContent = fs.readFileSync(containerPath, "utf-8"); + const lines = fileContent + .split("\n") + .filter((line) => line.trim()); + + const linesToKeep = Math.floor(lines.length / 2); + const newContent = `${lines.slice(-linesToKeep).join("\n")}\n`; + fs.writeFileSync(containerPath, newContent); + } } await fs.promises.appendFile(containerPath, logLine);