From f5ee5c4f340df1843e82b54e8a8835981aef6aa0 Mon Sep 17 00:00:00 2001 From: Greg Burri Date: Mon, 15 Mar 2021 16:44:11 +0100 Subject: [PATCH] Support systemd only on unix --- backend/Cargo.toml | 4 +++- backend/src/valheim_controller.rs | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) 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(); -- 2.45.2