Skip to content

Commit f781cee

Browse files
committed
debug: print lsof output
1 parent 634add0 commit f781cee

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/lib.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ use rand::Rng;
167167

168168
use std::default::Default;
169169
use std::net::ToSocketAddrs;
170+
use std::process::Command;
170171
use std::sync::{Arc, Mutex, RwLock};
171172
use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH};
172173

@@ -333,6 +334,23 @@ impl Node {
333334
listeners.push(listener);
334335
},
335336
Err(e) => {
337+
let pid = std::process::id();
338+
println!("Failed to bind to port {}: {} (this pid: {})", addr, e, pid);
339+
340+
let output = Command::new("lsof")
341+
.args(&["-i", &format!(":{}", &addr.port())])
342+
.output()
343+
.expect("failed to execute lsof");
344+
345+
println!("LSOF output: {}", String::from_utf8_lossy(&output.stdout));
346+
347+
let output = Command::new("netstat")
348+
.args(&["-an"])
349+
.output()
350+
.expect("failed to execute netstat");
351+
352+
println!("Netstat output: {}", String::from_utf8_lossy(&output.stdout));
353+
336354
log_error!(
337355
logger,
338356
"Failed to bind to {}: {} - is something else already listening?",

0 commit comments

Comments
 (0)