MCPcopy Create free account
hub / github.com/MCSManager/MCSManager / takeoverContainer

Function takeoverContainer

daemon/src/service/takeover_container.ts:13–40  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

11}
12
13export default async function takeoverContainer() {
14 const docker = new DefaultDocker();
15 const containers = new Map<string, ContainerInfo>();
16 (await docker.listContainers()).forEach((containerInfo) => {
17 const label = containerInfo.Labels["mcsmanager.instance.uuid"];
18 if (label == null) {
19 return;
20 }
21 if (containers.has(label)) {
22 return; // Skip if already exists
23 }
24 containers.set(label, containerInfo);
25 });
26
27 for (const item of containers) {
28 const [uuid, container] = item;
29 const instance = InstanceSubsystem.getInstance(uuid);
30 try {
31 if (instance && instance.config.processType == "docker") {
32 await instance.forceExec(new DockerTakeoverCommand(container));
33 }
34 } catch (e) {
35 docker.getContainer(container.Id).kill();
36 killContainer(container);
37 throw e;
38 }
39 }
40}

Callers 1

loadInstancesMethod · 0.85

Calls 6

killContainerFunction · 0.85
forceExecMethod · 0.80
getContainerMethod · 0.80
setMethod · 0.45
getInstanceMethod · 0.45
killMethod · 0.45

Tested by

no test coverage detected