From 41e436f3311cd023af9ed69fb63e3fbfc7bd0417 Mon Sep 17 00:00:00 2001 From: WhizSid Date: Tue, 22 Sep 2020 15:29:57 +0530 Subject: [PATCH] serve command exiting when web socket port is already in use (#1179) * Handled web socket port used issue * Lint --- src/cmd/serve.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/cmd/serve.rs b/src/cmd/serve.rs index b5e4e71d..de3e195c 100644 --- a/src/cmd/serve.rs +++ b/src/cmd/serve.rs @@ -326,10 +326,17 @@ pub fn serve( } }) .unwrap(); + let broadcaster = ws_server.broadcaster(); + + let ws_server = ws_server + .bind(&*ws_address) + .map_err(|_| format!("Address {} is already in use.", &ws_address))?; + thread::spawn(move || { - ws_server.listen(&*ws_address).unwrap(); + ws_server.run().unwrap(); }); + Some(broadcaster) } else { println!("Watching in watch only mode, no web server will be started");