mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
feat: add support for viewing docker logs in swarm mode
This commit is contained in:
@@ -4,6 +4,8 @@ import {
|
||||
getContainers,
|
||||
getContainersByAppLabel,
|
||||
getContainersByAppNameMatch,
|
||||
getServiceContainersByAppName,
|
||||
getStackContainersByAppName,
|
||||
} from "@dokploy/server";
|
||||
import { z } from "zod";
|
||||
import { createTRPCRouter, protectedProcedure } from "../trpc";
|
||||
@@ -68,4 +70,26 @@ export const dockerRouter = createTRPCRouter({
|
||||
.query(async ({ input }) => {
|
||||
return await getContainersByAppLabel(input.appName, input.serverId);
|
||||
}),
|
||||
|
||||
getStackContainersByAppName: protectedProcedure
|
||||
.input(
|
||||
z.object({
|
||||
appName: z.string().min(1),
|
||||
serverId: z.string().optional(),
|
||||
}),
|
||||
)
|
||||
.query(async ({ input }) => {
|
||||
return await getStackContainersByAppName(input.appName, input.serverId);
|
||||
}),
|
||||
|
||||
getServiceContainersByAppName: protectedProcedure
|
||||
.input(
|
||||
z.object({
|
||||
appName: z.string().min(1),
|
||||
serverId: z.string().optional(),
|
||||
}),
|
||||
)
|
||||
.query(async ({ input }) => {
|
||||
return await getServiceContainersByAppName(input.appName, input.serverId);
|
||||
}),
|
||||
});
|
||||
|
||||
@@ -34,6 +34,7 @@ export const setupDockerContainerLogsWebSocketServer = (
|
||||
const search = url.searchParams.get("search");
|
||||
const since = url.searchParams.get("since");
|
||||
const serverId = url.searchParams.get("serverId");
|
||||
const runType = url.searchParams.get("runType");
|
||||
const { user, session } = await validateWebSocketRequest(req);
|
||||
|
||||
if (!containerId) {
|
||||
@@ -53,7 +54,7 @@ export const setupDockerContainerLogsWebSocketServer = (
|
||||
const client = new Client();
|
||||
client
|
||||
.once("ready", () => {
|
||||
const baseCommand = `docker container logs --timestamps --tail ${tail} ${
|
||||
const baseCommand = `docker ${runType==="swarm"?"service":"container"} logs --timestamps --tail ${tail} ${
|
||||
since === "all" ? "" : `--since ${since}`
|
||||
} --follow ${containerId}`;
|
||||
const escapedSearch = search ? search.replace(/'/g, "'\\''") : "";
|
||||
@@ -97,7 +98,7 @@ export const setupDockerContainerLogsWebSocketServer = (
|
||||
});
|
||||
} else {
|
||||
const shell = getShell();
|
||||
const baseCommand = `docker container logs --timestamps --tail ${tail} ${
|
||||
const baseCommand = `docker ${runType==="swarm"?"service":"container"} logs --timestamps --tail ${tail} ${
|
||||
since === "all" ? "" : `--since ${since}`
|
||||
} --follow ${containerId}`;
|
||||
const command = search
|
||||
|
||||
Reference in New Issue
Block a user