mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
feat: add show cluster
This commit is contained in:
@@ -21,6 +21,7 @@ import { portRouter } from "./routers/port";
|
||||
import { adminRouter } from "./routers/admin";
|
||||
import { dockerRouter } from "./routers/docker";
|
||||
import { registryRouter } from "./routers/registry";
|
||||
import { clusterRouter } from "./routers/cluster";
|
||||
/**
|
||||
* This is the primary router for your server.
|
||||
*
|
||||
@@ -49,6 +50,7 @@ export const appRouter = createTRPCRouter({
|
||||
redirects: redirectsRouter,
|
||||
port: portRouter,
|
||||
registry: registryRouter,
|
||||
cluster: clusterRouter,
|
||||
});
|
||||
|
||||
// export type definition of API
|
||||
|
||||
17
server/api/routers/cluster.ts
Normal file
17
server/api/routers/cluster.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { docker } from "@/server/constants";
|
||||
import { createTRPCRouter, protectedProcedure } from "../trpc";
|
||||
import { getPublicIpWithFallback } from "@/server/wss/terminal";
|
||||
|
||||
export const clusterRouter = createTRPCRouter({
|
||||
getWorkers: protectedProcedure.query(async () => {
|
||||
const workers = await docker.listNodes();
|
||||
// console.log(workers);
|
||||
return workers;
|
||||
}),
|
||||
addWorker: protectedProcedure.query(async ({ input }) => {
|
||||
const result = await docker.swarmInspect();
|
||||
return `docker swarm join --token ${
|
||||
result.JoinTokens.Worker
|
||||
} ${await getPublicIpWithFallback()}:2377`;
|
||||
}),
|
||||
});
|
||||
Reference in New Issue
Block a user