|
1 | 1 | import subprocess |
2 | 2 | import sys |
3 | 3 | import tempfile |
| 4 | +from multiprocessing import Process |
4 | 5 | from pathlib import Path |
5 | 6 | from typing import Optional |
6 | 7 |
|
@@ -75,17 +76,44 @@ def _deploy(directory, debug, namespace, to_all_users): |
75 | 76 |
|
76 | 77 | if to_all_users: |
77 | 78 | namespaces = get_namespaces_by_type(WARGAMES_NAMESPACE_PREFIX) |
| 79 | + processes = [] |
78 | 80 | for namespace in namespaces: |
79 | | - deploy(directory, debug, namespace.metadata.name, False) |
| 81 | + p = Process(target=deploy, args=(directory, debug, namespace.metadata.name, False)) |
| 82 | + p.start() |
| 83 | + processes.append(p) |
| 84 | + for p in processes: |
| 85 | + p.join() |
80 | 86 | return |
81 | 87 |
|
82 | 88 | if (directory / NETWORK_FILE).exists(): |
83 | | - dl = deploy_logging_stack(directory, debug) |
84 | | - deploy_network(directory, debug, namespace=namespace) |
85 | | - df = deploy_fork_observer(directory, debug) |
86 | | - if dl | df: |
87 | | - deploy_ingress(debug) |
88 | | - deploy_caddy(directory, debug) |
| 89 | + processes = [] |
| 90 | + logging_process = Process(target=deploy_logging_stack, args=(directory, debug)) |
| 91 | + logging_process.start() |
| 92 | + processes.append(logging_process) |
| 93 | + |
| 94 | + network_process = Process(target=deploy_network, args=(directory, debug, namespace)) |
| 95 | + network_process.start() |
| 96 | + |
| 97 | + ingress_process = Process(target=deploy_ingress, args=(debug,)) |
| 98 | + ingress_process.start() |
| 99 | + processes.append(ingress_process) |
| 100 | + |
| 101 | + caddy_process = Process(target=deploy_caddy, args=(directory, debug)) |
| 102 | + caddy_process.start() |
| 103 | + processes.append(caddy_process) |
| 104 | + |
| 105 | + # Wait for the network process to complete |
| 106 | + network_process.join() |
| 107 | + |
| 108 | + # Start the fork observer process immediately after network process completes |
| 109 | + fork_observer_process = Process(target=deploy_fork_observer, args=(directory, debug)) |
| 110 | + fork_observer_process.start() |
| 111 | + processes.append(fork_observer_process) |
| 112 | + |
| 113 | + # Wait for all other processes to complete |
| 114 | + for p in processes: |
| 115 | + p.join() |
| 116 | + |
89 | 117 | elif (directory / NAMESPACES_FILE).exists(): |
90 | 118 | deploy_namespaces(directory) |
91 | 119 | else: |
|
0 commit comments