diff --git a/packages/server/src/utils/access-log/handler.ts b/packages/server/src/utils/access-log/handler.ts index 17b1c2543..0feae622c 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); }