X-Git-Url: http://git.euphorik.ch/index.cgi?a=blobdiff_plain;f=backend%2Fsrc%2Fmain.rs;h=c4d7d5053cda8d642c71e04845116e0db5fb064c;hb=55bef4c00d6f8f6d87fdf482ca63b5efcd85575e;hp=53fbe682efc6416d5bcbea65bf12afcee78c3ef4;hpb=9b09a05def141a8f5b08c822d886e9e9f9ba3050;p=minecraft_web.git diff --git a/backend/src/main.rs b/backend/src/main.rs index 53fbe68..c4d7d50 100644 --- a/backend/src/main.rs +++ b/backend/src/main.rs @@ -1,7 +1,6 @@ extern crate askama; 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; @@ -10,7 +9,6 @@ use serde::{ Deserialize, Serialize }; use cached::proc_macro::cached; mod consts; -mod tests; mod minecraft_controller; #[derive(Template)] @@ -28,15 +26,15 @@ struct MainTemplate { const VALUE_UNKNOWN: &str = "-"; #[cached(size = 1, time = 10)] -fn get_minecraft_executable_information_cached(world_path: String, backup_path: String) -> Option { - minecraft_controller::get_minecraft_executable_information(&world_path, &backup_path) +fn get_minecraft_executable_information_cached(world_path: String, backup_path: String, rcon_password: String) -> Option { + minecraft_controller::get_minecraft_executable_information(&world_path, &backup_path, &rcon_password) } #[get("/")] async fn main_page(config_shared: web::Data>) -> impl Responder { let config = config_shared.lock().unwrap(); - match get_minecraft_executable_information_cached(config.world_path.clone(), config.backup_path.clone()) { + match get_minecraft_executable_information_cached(config.world_path.clone(), config.backup_path.clone(), config.rcon_password.clone()) { Some(info) => MainTemplate { text_status: String::from("Minecraft server is up and running :)"), @@ -56,7 +54,8 @@ async fn main_page(config_shared: web::Data>) -> impl Responder { uptime: value_unknown.clone(), world_size: value_unknown.clone(), active_players: value_unknown.clone(), - last_backup: value_unknown.clone() } + last_backup: value_unknown.clone() + } } } } @@ -144,7 +143,7 @@ fn process_args(config: &Config) -> bool { print_usage(); return true } else if args.iter().any(|arg| arg == "--status") { - println!("{:?}", minecraft_controller::get_minecraft_executable_information(&config.world_path, &config.backup_path)); + println!("{:?}", minecraft_controller::get_minecraft_executable_information(&config.world_path, &config.backup_path, &config.rcon_password)); return true }