fix: remove run_container func from Docker Mananger - no need for exec

This commit is contained in:
Roman 2024-02-01 19:10:03 +08:00
parent 24e34b00a0
commit 0e6e62077b
No known key found for this signature in database
GPG Key ID: B8FE070B54E11B75
2 changed files with 0 additions and 30 deletions

View File

@ -55,30 +55,6 @@ class DockerManager:
return container
def run_container(self, image_name, ports, args, log_path, container_ip, volumes):
cli_args = []
for key, value in args.items():
if isinstance(value, list): # Check if value is a list
cli_args.extend([f"--{key}={item}" for item in value]) # Add a command for each item in the list
else:
cli_args.append(f"--{key}={value}") # Add a single command
port_bindings = {f"{port}/tcp": ("", port) for port in ports}
logger.debug(f"Running container with image {image_name}")
logger.debug(f"Using args {cli_args}")
container = self._client.containers.exec_run(
image_name, command=cli_args, ports=port_bindings, detach=True, remove=True, auto_remove=True, volumes=volumes
)
network = self._client.networks.get(NETWORK_NAME)
network.connect(container, ipv4_address=container_ip)
logger.debug(f"Container started with ID {container.short_id}. Setting up logs at {log_path}")
log_thread = threading.Thread(target=self._log_container_output, args=(container, log_path))
log_thread.daemon = True
log_thread.start()
return container
def _log_container_output(self, container, log_path):
os.makedirs(os.path.dirname(log_path), exist_ok=True)
with open(log_path, "wb+") as log_file:

View File

@ -107,15 +107,9 @@ class WakuNode:
)
if default_args["rln-register-only"]:
self._container = self._docker_manager.run_container(
self._docker_manager.image, self._ports, default_args, self._log_path, self._ext_ip, self._volumes
)
logger.debug(f"Executed container from image {self._image_name}. REST: {self._rest_port} to register RLN")
else:
self._container = self._docker_manager.start_container(
self._docker_manager.image, self._ports, default_args, self._log_path, self._ext_ip, self._volumes
)
logger.debug(f"Started container from image {self._image_name}. REST: {self._rest_port} with RLN enabled")
DS.waku_nodes.append(self)
delay(1) # if we fire requests to soon after starting the node will sometimes fail to start correctly