version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
+[[package]]
+name = "listenfd"
+version = "0.3.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)",
+ "uuid 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
[[package]]
name = "lock_api"
version = "0.1.5"
"actix-files 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"actix-web 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"askama 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "listenfd 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)",
]
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
+[[package]]
+name = "uuid"
+version = "0.6.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
[[package]]
name = "v_escape"
version = "0.7.2"
"checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14"
"checksum libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)" = "6281b86796ba5e4366000be6e9e18bf35580adf9e63fbe2294aadb587613a319"
"checksum linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ae91b68aebc4ddb91978b11a1b02ddd8602a05ec19002801c5666000e05e0f83"
+"checksum listenfd 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "492158e732f2e2de81c592f0a2427e57e12cd3d59877378fe7af624b6bbe0ca1"
"checksum lock_api 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c"
"checksum lock_api 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ed946d4529956a20f2d63ebe1b69996d5a2137c91913fe3ebbeff957f5bca7ff"
"checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6"
"checksum untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "55cd1f4b4e96b46aeb8d4855db4a7a9bd96eeeb5c6a1ab54593328761642ce2f"
"checksum url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a"
"checksum utf8-ranges 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "9d50aa7650df78abf942826607c62468ce18d9019673d4a2ebe1865dbb96ffde"
+"checksum uuid 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e1436e58182935dcd9ce0add9ea0b558e8a87befe01c1a301e6020aeb0876363"
"checksum v_escape 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8865501b78eef9193c1b45486acf18ba889e5662eba98854d6fc59d8ecf3542d"
"checksum v_escape_derive 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "306896ff4b75998501263a1dc000456de442e21d68fe8c8bdf75c66a33a58e23"
"checksum v_htmlescape 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7fbbe0fa88dd36f9c8cf61a218d4b953ba669de4d0785832f33cc72bd081e1be"
extern crate actix_web;
+extern crate listenfd;
extern crate askama;
+use listenfd::ListenFd;
use actix_files as fs;
use actix_web::{web, middleware, App, HttpServer, HttpResponse, Responder, Result, web::Query};
use askama::Template;
}
fn main() -> std::io::Result<()> {
- HttpServer::new(
- || {
- App::new()
- .wrap(middleware::Compress::default())
- .wrap(middleware::Logger::default())
- .service(web::resource("/").to(main_page))
- .service(fs::Files::new("/static", "static").show_files_listing())
- }
- )
- .bind("0.0.0.0:8082")
- .expect("Can not bind to port 8082")
- .run()
+ let mut listenfd = ListenFd::from_env();
+ let mut server =
+ HttpServer::new(
+ || {
+ App::new()
+ .wrap(middleware::Compress::default())
+ .wrap(middleware::Logger::default())
+ .service(web::resource("/").to(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("0.0.0.0:8082").unwrap()
+ };
+
+ server.run()
}