Skip to content

Commit 32cdfd3

Browse files
committed
speedy startup tanks
1 parent 38adc3e commit 32cdfd3

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
@@ -259,41 +259,49 @@ def deploy_fork_observer(directory: Path, debug: bool) -> bool:
259259

260260
def deploy_network(directory: Path, debug: bool = False, namespace: Optional[str] = None):
261261
network_file_path = directory / NETWORK_FILE
262-
defaults_file_path = directory / DEFAULTS_FILE
263-
264262
namespace = get_default_namespace_or(namespace)
265263

266264
with network_file_path.open() as f:
267265
network_file = yaml.safe_load(f)
268266

267+
processes = []
269268
for node in network_file["nodes"]:
270-
click.echo(f"Deploying node: {node.get('name')}")
271-
try:
272-
temp_override_file_path = ""
273-
node_name = node.get("name")
274-
node_config_override = {k: v for k, v in node.items() if k != "name"}
269+
p = Process(target=deploy_single_node, args=(node, directory, debug, namespace))
270+
p.start()
271+
processes.append(p)
275272

276-
cmd = f"{HELM_COMMAND} {node_name} {BITCOIN_CHART_LOCATION} --namespace {namespace} -f {defaults_file_path}"
277-
if debug:
278-
cmd += " --debug"
273+
for p in processes:
274+
p.join()
279275

280-
if node_config_override:
281-
with tempfile.NamedTemporaryFile(
282-
mode="w", suffix=".yaml", delete=False
283-
) as temp_file:
284-
yaml.dump(node_config_override, temp_file)
285-
temp_override_file_path = Path(temp_file.name)
286-
cmd = f"{cmd} -f {temp_override_file_path}"
287276

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

298306

299307
def deploy_namespaces(directory: Path):

0 commit comments

Comments
 (0)