Skip to content

Commit 06c7a76

Browse files
committed
speedy startup tanks
1 parent 3bd7043 commit 06c7a76

File tree

1 file changed

+33
-25
lines changed

1 file changed

+33
-25
lines changed

src/warnet/deploy.py

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -253,41 +253,49 @@ def deploy_fork_observer(directory: Path, debug: bool) -> bool:
253253

254254
def deploy_network(directory: Path, debug: bool = False, namespace: Optional[str] = None):
255255
network_file_path = directory / NETWORK_FILE
256-
defaults_file_path = directory / DEFAULTS_FILE
257-
258256
namespace = get_default_namespace_or(namespace)
259257

260258
with network_file_path.open() as f:
261259
network_file = yaml.safe_load(f)
262260

261+
processes = []
263262
for node in network_file["nodes"]:
264-
click.echo(f"Deploying node: {node.get('name')}")
265-
try:
266-
temp_override_file_path = ""
267-
node_name = node.get("name")
268-
node_config_override = {k: v for k, v in node.items() if k != "name"}
263+
p = Process(target=deploy_single_node, args=(node, directory, debug, namespace))
264+
p.start()
265+
processes.append(p)
269266

270-
cmd = f"{HELM_COMMAND} {node_name} {BITCOIN_CHART_LOCATION} --namespace {namespace} -f {defaults_file_path}"
271-
if debug:
272-
cmd += " --debug"
267+
for p in processes:
268+
p.join()
273269

274-
if node_config_override:
275-
with tempfile.NamedTemporaryFile(
276-
mode="w", suffix=".yaml", delete=False
277-
) as temp_file:
278-
yaml.dump(node_config_override, temp_file)
279-
temp_override_file_path = Path(temp_file.name)
280-
cmd = f"{cmd} -f {temp_override_file_path}"
281270

282-
if not stream_command(cmd):
283-
click.echo(f"Failed to run Helm command: {cmd}")
284-
return
285-
except Exception as e:
286-
click.echo(f"Error: {e}")
271+
def deploy_single_node(node, directory: Path, debug: bool, namespace: str):
272+
defaults_file_path = directory / DEFAULTS_FILE
273+
click.echo(f"Deploying node: {node.get('name')}")
274+
temp_override_file_path = ""
275+
try:
276+
node_name = node.get("name")
277+
node_config_override = {k: v for k, v in node.items() if k != "name"}
278+
279+
defaults_file_path = directory / DEFAULTS_FILE
280+
cmd = f"{HELM_COMMAND} {node_name} {BITCOIN_CHART_LOCATION} --namespace {namespace} -f {defaults_file_path}"
281+
if debug:
282+
cmd += " --debug"
283+
284+
if node_config_override:
285+
with tempfile.NamedTemporaryFile(mode="w", suffix=".yaml", delete=False) as temp_file:
286+
yaml.dump(node_config_override, temp_file)
287+
temp_override_file_path = Path(temp_file.name)
288+
cmd = f"{cmd} -f {temp_override_file_path}"
289+
290+
if not stream_command(cmd):
291+
click.echo(f"Failed to run Helm command: {cmd}")
287292
return
288-
finally:
289-
if temp_override_file_path:
290-
Path(temp_override_file_path).unlink()
293+
except Exception as e:
294+
click.echo(f"Error: {e}")
295+
return
296+
finally:
297+
if temp_override_file_path:
298+
Path(temp_override_file_path).unlink()
291299

292300

293301
def deploy_namespaces(directory: Path):

0 commit comments

Comments
 (0)