// Create static directory if it doesn't exist.
if !Path::new("static").exists() {
- std::fs::create_dir("static");
+ std::fs::create_dir("static").unwrap();
}
let output =
// use futures::sink::With;
use listenfd::ListenFd;
use actix_files as fs;
-use actix_web::{ get, Responder, middleware, App, HttpServer, web::Query };
+use actix_web::{ get, Responder, middleware, App, HttpServer };
use askama::Template;
use std::{ /*sync::Mutex, */fs::File, env::args, io::prelude::* };
world_size: String
}
-#[derive(Deserialize)]
-pub struct Request {
- m: Option<String>
-}
-
const VALUE_UNKNOWN: &str = "-";
#[get("/")]
-async fn main_page(/*key_shared: web::Data<Mutex<String>>,*/ query: Query<Request>) -> impl Responder {
+async fn main_page() -> impl Responder {
//let key = key_shared.lock().unwrap();
match valheim_controller::get_valheim_executable_information() {
MainTemplate { text_status: String::from("Valheim server is down :("), memory: value_unknown.clone(), load_average: value_unknown.clone(), uptime: value_unknown.clone(), world_size: value_unknown.clone() }
}
}
-
- /*
-
- let m =
- if valheim_controller::is_valheim_running() { String::from("Valheim server is up and running") } else { String::from("Valheim server is down :(") };
-
- MainTemplate { sentence: m }
- */
}
#[derive(Debug, Deserialize, Serialize)]
-use sysinfo::{ComponentExt, ProcessExt, SystemExt};\r
+use sysinfo::{ProcessExt, SystemExt};\r
\r
#[derive(Debug)]\r
pub struct ValheimExe {\r
fn format_byte_size(bytes: u64, precision: usize) -> String {\r
for i in 0 .. 8 {\r
let mut size: u64 = 1;\r
- for j in 0 .. i {\r
- size *= 1024;\r
- }\r
+ size *= 1024u64.pow(i as u32);\r
\r
if bytes < 1024 {\r
return format!("{} {}", std::cmp::max(0u64, bytes), BINARY_PREFIXES[i]);\r