From e8c4d536cfa20585aa28c554ca619c5a803682c6 Mon Sep 17 00:00:00 2001 From: Roland Sherwin Date: Mon, 10 Jun 2024 18:33:35 +0530 Subject: [PATCH] fix(manager): store node port inside during start --- sn_service_management/src/node.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/sn_service_management/src/node.rs b/sn_service_management/src/node.rs index b302e803c0..4bca063d2c 100644 --- a/sn_service_management/src/node.rs +++ b/sn_service_management/src/node.rs @@ -146,10 +146,27 @@ impl<'a> ServiceStateActions for NodeService<'a> { self.service_data.listen_addr = Some( network_info .listeners - .into_iter() + .iter() + .cloned() .map(|addr| addr.with(Protocol::P2p(node_info.peer_id))) .collect(), ); + + for addr in &network_info.listeners { + if let Some(port) = get_port_from_multiaddr(addr) { + debug!( + "Found safenode port for {}: {port}", + self.service_data.service_name + ); + self.service_data.node_port = Some(port); + break; + } + } + + if self.service_data.node_port.is_none() { + error!("Could not find safenode port. This will cause the node to have a different port during upgrade"); + } + self.service_data.pid = Some(node_info.pid); self.service_data.peer_id = Some(node_info.peer_id); self.service_data.status = ServiceStatus::Running;