From c4620d6f981e84059c464604969a55ff085152f6 Mon Sep 17 00:00:00 2001 From: Greg Burri Date: Thu, 11 Mar 2021 14:19:05 +0100 Subject: [PATCH] Replace 'listenfd' by 'cargo watch' --- Cargo.lock | 33 ++++++--------------------------- backend/Cargo.toml | 1 - backend/launch_debug.ps1 | 2 +- backend/src/main.rs | 24 +++++++----------------- 4 files changed, 14 insertions(+), 46 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d6d86c1..0d1303a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -390,9 +390,9 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.47" +version = "0.1.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e098e9c493fdf92832223594d9a164f96bdf17ba81a42aff86f85c76768726a" +checksum = "36ea56748e10732c49404c153638a15ec3d6211ec5ff35d9bb20e13b93576adf" dependencies = [ "proc-macro2", "quote", @@ -482,9 +482,9 @@ dependencies = [ [[package]] name = "byteorder" -version = "1.4.2" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae44d1a3d5a19df61dd0c8beb138458ac2a53a7ac09eba97d55592540004306b" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "bytes" @@ -1020,17 +1020,6 @@ version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3" -[[package]] -name = "listenfd" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "492158e732f2e2de81c592f0a2427e57e12cd3d59877378fe7af624b6bbe0ca1" -dependencies = [ - "libc", - "uuid", - "winapi 0.3.9", -] - [[package]] name = "lock_api" version = "0.4.2" @@ -1580,9 +1569,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.62" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "123a78a3596b24fee53a6464ce52d8ecbf62241e6294c7e7fe12086cd161f512" +checksum = "8fd9bc7ccc2688b3344c2f48b9b546648b25ce0b20fc717ee7fa7981a8ca9717" dependencies = [ "proc-macro2", "quote", @@ -1839,15 +1828,6 @@ dependencies = [ "percent-encoding", ] -[[package]] -name = "uuid" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1436e58182935dcd9ce0add9ea0b558e8a87befe01c1a301e6020aeb0876363" -dependencies = [ - "cfg-if 0.1.10", -] - [[package]] name = "v_escape" version = "0.7.4" @@ -1890,7 +1870,6 @@ dependencies = [ "common", "futures", "itertools", - "listenfd", "ron", "serde", "sysinfo", diff --git a/backend/Cargo.toml b/backend/Cargo.toml index 944bf96..5a4b1e1 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -10,7 +10,6 @@ actix-rt = "1" actix-files = "0.2" serde = { version = "1.0", features = ["derive"] } -listenfd = "0.3" # To watch file modifications and automatically launch a build process (only used in dev/debug). ron = "0.6" # Rust object notation, to load configuration files. itertools = "0.10" diff --git a/backend/launch_debug.ps1 b/backend/launch_debug.ps1 index 5e284b2..c0ed2bc 100644 --- a/backend/launch_debug.ps1 +++ b/backend/launch_debug.ps1 @@ -1,2 +1,2 @@ # To launch the web server and watching source. See https://actix.rs/docs/autoreload/. -systemfd --no-pid -s http::8082 -- cargo watch -x run \ No newline at end of file +cargo watch -x 'run' \ No newline at end of file diff --git a/backend/src/main.rs b/backend/src/main.rs index a711427..c4c51a0 100644 --- a/backend/src/main.rs +++ b/backend/src/main.rs @@ -1,14 +1,10 @@ - -extern crate listenfd; extern crate askama; -// use futures::sink::With; -use listenfd::ListenFd; +use std::{ sync::Mutex, env::args, fs::File, io::prelude::* }; + use actix_files as fs; use actix_web::{ get, web, Responder, middleware, App, HttpServer }; use askama::Template; - -use std::{ sync::Mutex, env::args, fs::File, io::prelude::* }; use ron::{ de::from_reader, ser::{ to_string_pretty, PrettyConfig } }; use serde::{ Deserialize, Serialize }; @@ -55,7 +51,7 @@ struct Config { world_path: String, } -fn empty_string() -> String { "".to_string() } +fn empty_string() -> String { "".to_owned() } impl Config { fn default() -> Self { @@ -95,8 +91,7 @@ async fn main() -> std::io::Result<()> { let config_shared = web::Data::new(Mutex::new(config)); - let mut listenfd = ListenFd::from_env(); - let mut server = + let server = HttpServer::new( move || { App::new() @@ -106,14 +101,9 @@ async fn main() -> std::io::Result<()> { .service(main_page) .service(fs::Files::new("/static", "static").show_files_listing()) } - ); - - server = - if let Some(l) = listenfd.take_tcp_listener(0).unwrap() { - server.listen(l).unwrap() - } else { - server.bind(&format!("0.0.0.0:{}", port)).unwrap() - }; + ) + .bind(&format!("0.0.0.0:{}", port)) + .unwrap(); server.run().await } -- 2.45.2