-async fn main_page(/*key_shared: web::Data<Mutex<String>>,*/ query: Query<Request>) -> impl Responder {
- //let key = key_shared.lock().unwrap();
-
- 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 }
+async fn main_page(config_shared: web::Data<Mutex<Config>>) -> impl Responder {
+ let config = config_shared.lock().unwrap();
+
+ match get_valheim_executable_information_cached(config.world_path.clone(), config.backup_path.clone()) {
+ Some(info) =>
+ MainTemplate {
+ text_status: String::from("Valheim server is up and running :)"),
+ memory: info.format_memory(),
+ load_average: info.format_load_average(),
+ uptime: info.format_uptime(),
+ world_size: info.format_world_size(),
+ active_players: info.format_active_players(),
+ last_backup: info.format_last_backup()
+ },
+ None => {
+ let value_unknown = String::from(VALUE_UNKNOWN);
+ 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(),
+ active_players: value_unknown.clone(),
+ last_backup: value_unknown.clone() }
+ }
+ }