diff --git a/apps/dokploy/components/dashboard/requests/show-requests.tsx b/apps/dokploy/components/dashboard/requests/show-requests.tsx index e510488a..03e11507 100644 --- a/apps/dokploy/components/dashboard/requests/show-requests.tsx +++ b/apps/dokploy/components/dashboard/requests/show-requests.tsx @@ -24,6 +24,11 @@ export const ShowRequests = () => { const { mutateAsync: deactivateLogRotate } = api.settings.deactivateLogRotate.useMutation(); + const { data: isActive, refetch } = + api.settings.haveActivateRequests.useQuery(); + const { mutateAsync: toggleRequests } = + api.settings.toggleRequests.useMutation(); + return ( <> @@ -33,39 +38,62 @@ export const ShowRequests = () => { Showing web and API requests over time - {!isLogRotateActive && ( +
- )} - - {isLogRotateActive && ( - - )} + {!isLogRotateActive && ( + + )} + {isLogRotateActive && ( + + )} +
diff --git a/apps/dokploy/server/api/routers/settings.ts b/apps/dokploy/server/api/routers/settings.ts index f34778ee..59fcdec1 100644 --- a/apps/dokploy/server/api/routers/settings.ts +++ b/apps/dokploy/server/api/routers/settings.ts @@ -53,6 +53,7 @@ import { } from "../services/settings"; import { canAccessToTraefikFiles } from "../services/user"; import { adminProcedure, createTRPCRouter, protectedProcedure } from "../trpc"; +import { dump, load } from "js-yaml"; export const settingsRouter = createTRPCRouter({ reloadServer: adminProcedure.mutation(async () => { @@ -382,4 +383,64 @@ export const settingsRouter = createTRPCRouter({ getLogRotateStatus: adminProcedure.query(async () => { return await logRotationManager.getStatus(); }), + haveActivateRequests: adminProcedure.query(async () => { + const config = readMainConfig(); + + if (!config) return false; + const parsedConfig = load(config) as { + accessLog?: { + filePath: string; + }; + }; + + return !!parsedConfig?.accessLog?.filePath; + }), + toggleRequests: adminProcedure + .input( + z.object({ + enable: z.boolean(), + }), + ) + .mutation(async ({ input }) => { + const config = readMainConfig(); + if (!config) return false; + + if (input.enable) { + const parsedConfig = load(config) as { + accessLog?: { + filePath: string; + format: string; + bufferingSize: number; + filters?: { + retryAttempts?: boolean; + minDuration?: string; + }; + }; + }; + const config2 = { + accessLog: { + filePath: "/etc/dokploy/traefik/dynamic/access.log", + format: "json", + bufferingSize: 100, + filters: { + retryAttempts: true, + minDuration: "10ms", + }, + }, + }; + parsedConfig.accessLog = config2.accessLog; + writeMainConfig(dump(parsedConfig)); + } else { + const parsedConfig = load(config) as { + accessLog?: { + filePath: string; + }; + }; + + delete parsedConfig.accessLog; + writeMainConfig(dump(parsedConfig)); + } + + return true; + }), }); diff --git a/apps/dokploy/server/api/services/application.ts b/apps/dokploy/server/api/services/application.ts index e712eec4..1e757027 100644 --- a/apps/dokploy/server/api/services/application.ts +++ b/apps/dokploy/server/api/services/application.ts @@ -59,12 +59,6 @@ export const createApplication = async ( if (process.env.NODE_ENV === "development") { createTraefikConfig(newApplication.appName); - await tx.insert(domains).values({ - applicationId: newApplication.applicationId, - host: `${newApplication.appName}.docker.localhost`, - port: process.env.NODE_ENV === "development" ? 3000 : 80, - certificateType: "none", - }); } return newApplication; diff --git a/apps/dokploy/server/utils/traefik/application.ts b/apps/dokploy/server/utils/traefik/application.ts index 52531c6e..87216fb3 100644 --- a/apps/dokploy/server/utils/traefik/application.ts +++ b/apps/dokploy/server/utils/traefik/application.ts @@ -1,7 +1,7 @@ import fs, { writeFileSync } from "node:fs"; import path from "node:path"; import type { Domain } from "@/server/api/services/domain"; -import { DYNAMIC_TRAEFIK_PATH } from "@/server/constants"; +import { DYNAMIC_TRAEFIK_PATH, MAIN_TRAEFIK_PATH } from "@/server/constants"; import { dump, load } from "js-yaml"; import type { FileConfig, HttpLoadBalancerService } from "./file-types";