projects
/
valheim_web.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Replace 'listenfd' by 'cargo watch'
[valheim_web.git]
/
backend
/
src
/
main.rs
diff --git
a/backend/src/main.rs
b/backend/src/main.rs
index
a711427
..
c4c51a0
100644
(file)
--- a/
backend/src/main.rs
+++ b/
backend/src/main.rs
@@
-1,14
+1,10
@@
-
-extern crate listenfd;
extern crate askama;
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 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 };
use ron::{ de::from_reader, ser::{ to_string_pretty, PrettyConfig } };
use serde::{ Deserialize, Serialize };
@@
-55,7
+51,7
@@
struct Config {
world_path: String,
}
world_path: String,
}
-fn empty_string() -> String { "".to_
string
() }
+fn empty_string() -> String { "".to_
owned
() }
impl Config {
fn default() -> Self {
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 config_shared = web::Data::new(Mutex::new(config));
- let mut listenfd = ListenFd::from_env();
- let mut server =
+ let server =
HttpServer::new(
move || {
App::new()
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())
}
.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
}
server.run().await
}