MCPcopy
hub / github.com/Dokploy/dokploy / checkSwarmResources

Function checkSwarmResources

packages/server/src/utils/gpu-setup.ts:127–157  ·  view source on GitHub ↗
(serverId?: string)

Source from the content-addressed store, hash-verified

125};
126
127const checkSwarmResources = async (serverId?: string) => {
128 let swarmEnabled = false;
129 let gpuResources = 0;
130
131 try {
132 const nodeCommand =
133 "docker node inspect self --format '{{json .Description.Resources.GenericResources}}'";
134 const { stdout: resources } = serverId
135 ? await execAsyncRemote(serverId, nodeCommand)
136 : await execAsync(nodeCommand);
137
138 if (resources && resources !== "null") {
139 const genericResources = JSON.parse(resources);
140 for (const resource of genericResources) {
141 if (
142 resource.DiscreteResourceSpec &&
143 (resource.DiscreteResourceSpec.Kind === "GPU" ||
144 resource.DiscreteResourceSpec.Kind === "gpu")
145 ) {
146 gpuResources = resource.DiscreteResourceSpec.Value;
147 swarmEnabled = true;
148 break;
149 }
150 }
151 }
152 } catch (error) {
153 console.debug("Swarm resource check:", error);
154 }
155
156 return { swarmEnabled, gpuResources };
157};
158
159const checkGpuInfo = async (serverId?: string) => {
160 let gpuModel: string | undefined;

Callers 1

checkGPUStatusFunction · 0.85

Calls 2

execAsyncRemoteFunction · 0.90
execAsyncFunction · 0.90

Tested by

no test coverage detected