From: Greg Burri Date: Mon, 15 Mar 2021 15:44:11 +0000 (+0100) Subject: Support systemd only on unix X-Git-Url: http://git.euphorik.ch/index.cgi?p=valheim_web.git;a=commitdiff_plain;h=f5ee5c4f340df1843e82b54e8a8835981aef6aa0 Support systemd only on unix --- diff --git a/backend/Cargo.toml b/backend/Cargo.toml index af3667c..351f710 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -14,7 +14,6 @@ ron = "0.6" # Rust object notation, to load configuration files. itertools = "0.10" sysinfo = "0.16" -systemd = "0.8" cached = "0.23" @@ -26,3 +25,6 @@ common = { path = "../common" } [dependencies.askama] version = "0.9" features = ["with-actix-web"] + +[target.'cfg(unix)'.dependencies] +systemd = "0.8" \ No newline at end of file diff --git a/backend/src/valheim_controller.rs b/backend/src/valheim_controller.rs index 414cee1..3c2bab6 100644 --- a/backend/src/valheim_controller.rs +++ b/backend/src/valheim_controller.rs @@ -1,4 +1,6 @@ use sysinfo::{ ProcessExt, SystemExt }; + +#[cfg(target_os = "unix")] use systemd::journal; #[derive(Clone, Debug)] @@ -55,6 +57,7 @@ fn format_byte_size(bytes: u64, precision: usize) -> String { const VALHEIM_PROCESS_NAME: &str = "valheim_server"; +#[cfg(target_os = "unix")] fn get_number_of_players() -> u32 { let mut journal = journal::OpenOptions::default().current_user(true).open().unwrap(); @@ -82,6 +85,11 @@ fn get_number_of_players() -> u32 { } } +#[cfg(target_os = "windows")] +fn get_number_of_players() -> u32 { + 0 +} + pub fn get_valheim_executable_information(world_path : &str) -> Option { let mut system = sysinfo::System::new_all(); system.refresh_system();