Skip to content

Commit

Permalink
refactor(manager): remove unused service method
Browse files Browse the repository at this point in the history
  • Loading branch information
RolandSherwin authored and joshuef committed Jan 31, 2024
1 parent 521a1ce commit f7965a2
Showing 1 changed file with 0 additions and 12 deletions.
12 changes: 0 additions & 12 deletions sn_node_manager/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ pub trait ServiceControl {
fn create_service_user(&self, username: &str) -> Result<()>;
fn get_available_port(&self) -> Result<u16>;
fn install(&self, config: ServiceConfig) -> Result<()>;
fn is_port_free(&self, port: u16) -> bool;
fn is_service_process_running(&self, pid: u32) -> bool;
fn start(&self, service_name: &str) -> Result<()>;
fn stop(&self, service_name: &str) -> Result<()>;
Expand Down Expand Up @@ -150,17 +149,6 @@ impl ServiceControl for NodeServiceManager {
Ok(())
}

fn is_port_free(&self, port: u16) -> bool {
let socket = TcpListener::bind(("127.0.0.1", port));
let is_free = socket.is_ok();
drop(socket);
// Sleep a little while to make sure that we've dropped the socket.
// Without the delay, we may face 'Port already in use' error, when trying to re-use this port.
sleep(PORT_UNBINDING_DELAY);

is_free
}

fn is_service_process_running(&self, pid: u32) -> bool {
let mut system = System::new_all();
system.refresh_all();
Expand Down

0 comments on commit f7965a2

Please sign in to comment.