From 766da4c7683720a50631104e3225e1d4b9234bc5 Mon Sep 17 00:00:00 2001 From: Mauricio Siu Date: Tue, 16 Jun 2026 07:29:05 -0600 Subject: [PATCH] fix: resolve traefik container dynamically in access-log cleanup The nightly access-log-cleanup job hardcoded "dokploy-traefik" as the container name when sending SIGUSR1. In Docker Swarm mode Traefik runs as a service task named "dokploy-traefik.1.", so `docker exec dokploy-traefik` fails every night with "No such container". The log file is rotated (inode changes) but Traefik never reopens it, leaving the on-disk access.log frozen while real logs go to a deleted file handle. Resolve the running container id dynamically with `docker ps --filter`, matching the pattern already used elsewhere in the codebase, so it works for both standalone and swarm deployments. Skip gracefully if no running container is found. Closes #4620 --- packages/server/src/utils/access-log/handler.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/server/src/utils/access-log/handler.ts b/packages/server/src/utils/access-log/handler.ts index 17b1c25432..0feae622cf 100644 --- a/packages/server/src/utils/access-log/handler.ts +++ b/packages/server/src/utils/access-log/handler.ts @@ -32,7 +32,19 @@ export const startLogCleanup = async ( await execAsync( `tail -n 1000 ${accessLogPath} > ${accessLogPath}.tmp && mv ${accessLogPath}.tmp ${accessLogPath}`, ); - await execAsync("docker exec dokploy-traefik kill -USR1 1"); + + // Traefik can run as a standalone container ("dokploy-traefik") or a + // swarm service task ("dokploy-traefik.1."), so resolve the + // running container id dynamically instead of assuming the name. + const { stdout: containerId } = await execAsync( + 'docker ps -q --filter "name=dokploy-traefik" --filter "status=running" | head -n 1', + ); + const traefikContainerId = containerId.trim(); + if (!traefikContainerId) { + console.error("Traefik container not found, skipping log reopen"); + return; + } + await execAsync(`docker exec ${traefikContainerId} kill -USR1 1`); } catch (error) { console.error("Error during log cleanup:", error); }