@@ -16,14 +16,19 @@ impl DeploymentManager {
1616 Self { process, setup }
1717 }
1818
19- pub async fn deploy_nodes ( & self , deployment_id : & str , node_type : NodeType , count : usize ) {
19+ pub async fn deploy_nodes ( & self , deployment_id : & str , node_type : NodeType , count : usize , config : Option < crate :: api :: deployment :: DeploymentConfig > ) -> Vec < crate :: api :: NodeInfo > {
2020 tracing:: info!(
2121 "Starting deployment {}: deploying {} {:?} nodes" ,
2222 deployment_id,
2323 count,
2424 node_type
2525 ) ;
2626
27+ // Extract DHT config or use defaults
28+ let enable_dht = config. as_ref ( ) . and_then ( |c| c. enable_dht ) . unwrap_or ( false ) ;
29+ let bootstrap_nodes = config. as_ref ( ) . and_then ( |c| c. bootstrap_nodes . clone ( ) ) . unwrap_or_default ( ) ;
30+ let key_seed = config. as_ref ( ) . and_then ( |c| c. key_seed . clone ( ) ) ;
31+
2732 // Find the highest used port to avoid conflicts
2833 // Using higher ports (19000+) to avoid conflicts with system services
2934 let mut base_port = match node_type {
@@ -60,6 +65,7 @@ impl DeploymentManager {
6065 }
6166
6267 let base_rpc_port = base_port + 1000 ;
68+ let mut deployed_nodes = Vec :: new ( ) ;
6369
6470 for i in 0 ..count {
6571 let node_id = format ! ( "{:?}-{}-{}" , node_type, deployment_id, i) ;
@@ -74,19 +80,13 @@ impl DeploymentManager {
7480 rpc_port,
7581 log_level : "info" . to_string ( ) ,
7682 network : "testnet" . to_string ( ) ,
83+ enable_dht,
84+ bootstrap_nodes : bootstrap_nodes. clone ( ) ,
85+ key_seed : key_seed. clone ( ) ,
7786 } ;
7887
79- // Register the node (but don't start it automatically)
80- // Note: The UI calls start_node separately, or we could start it here.
81- // But wait, the UI "Deploy" button calls deploy_node, which spawns this task.
82- // The UI then refreshes the list. It doesn't automatically start them?
83- // The screenshot shows them as "Running".
84- // Let's check process.rs start_node again.
85- // Ah, register_node returns NodeStatus::Stopped.
86- // So the user must have clicked Start.
87- // But wait, if I register them in SetupManager, they appear in the list.
88-
89- self . process . register_node ( node_id. clone ( ) , config) ;
88+ // Register the node
89+ let mut node_info = self . process . register_node ( node_id. clone ( ) , config) ;
9090
9191 // Register in SetupManager so metrics can be fetched
9292 let endpoint = NodeEndpoint {
@@ -100,9 +100,16 @@ impl DeploymentManager {
100100 tracing:: info!( "Registered node '{}' in deployment {}" , node_id, deployment_id) ;
101101
102102 // Auto-start the node for convenience
103- if let Err ( e) = self . process . start_node ( & node_id) {
104- tracing:: error!( "Failed to auto-start node {}: {}" , node_id, e) ;
103+ match self . process . start_node ( & node_id) {
104+ Ok ( started_info) => {
105+ node_info = started_info;
106+ } ,
107+ Err ( e) => {
108+ tracing:: error!( "Failed to auto-start node {}: {}" , node_id, e) ;
109+ }
105110 }
111+
112+ deployed_nodes. push ( node_info) ;
106113 }
107114
108115 // Save setup state
@@ -117,5 +124,7 @@ impl DeploymentManager {
117124 count,
118125 node_type
119126 ) ;
127+
128+ deployed_nodes
120129 }
121130}
0 commit comments