Skip to content

Commit

Permalink
Fix is_port_in_use
Browse files Browse the repository at this point in the history
  • Loading branch information
matias-gonz committed Oct 14, 2024
1 parent a5253a0 commit 06b34eb
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions zkstack_cli/crates/zkstack/src/commands/dev/commands/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,7 @@ fn print_status(health_check_url: String) -> anyhow::Result<()> {
}

fn is_port_in_use(port: u16) -> bool {
match TcpListener::bind(("127.0.0.1", port)) {
Ok(_listener) => false,
Err(_e) => true,
}
TcpListener::bind(("0.0.0.0", port)).is_err() || TcpListener::bind(("127.0.0.1", port)).is_err()
}

fn print_ports(shell: &Shell) -> anyhow::Result<()> {
Expand All @@ -195,8 +192,8 @@ fn print_ports(shell: &Shell) -> anyhow::Result<()> {
};

port_info_lines.push_str(&format!(
" - {} > {}{}\n",
port_info.port, port_info.description, in_use_tag
" - {}{} > {}\n",
port_info.port, in_use_tag, port_info.description
));
}

Expand All @@ -210,7 +207,7 @@ fn print_ports(shell: &Shell) -> anyhow::Result<()> {
.then_with(|| a.cmp(b))
});

let mut components_info = String::from("Used ports:\n");
let mut components_info = String::new();
for chunk in all_port_lines.chunks(2) {
components_info.push_str(&bordered_boxes(&chunk[0], chunk.get(1)));
}
Expand Down

0 comments on commit 06b34eb

Please sign in to comment.