()
| 11 | } |
| 12 | |
| 13 | export 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 | } |
no test coverage detected