Fix sysinfo (#454)

* Fix sysinfo

* dep
This commit is contained in:
Michael
2021-09-28 13:22:41 -07:00
committed by GitHub
parent ce41246936
commit 02971e3589
7 changed files with 55 additions and 43 deletions

21
.gitattributes vendored Normal file
View File

@@ -0,0 +1,21 @@
* text=auto eol=lf
*.txt text
*.vcproj text eol=crlf
*.sh text eol=lf
*.rs text eol=lf
*.c text eol=lf
*.h text eol=lf
*.cpp text eol=lf
*.hpp text eol=lf
*.cc text eol=lf
*.hh text eol=lf
*.cxx text eol=lf
*.hxx text eol=lf
*.c++ text eol=lf
*.h++ text eol=lf
*.cs text eol=lf
*.vb text eol=lf
*.bas text eol=lf
*.frm text eol=lf
*.jpg -text
*.png -textgh

33
Cargo.lock generated
View File

@@ -273,12 +273,6 @@ dependencies = [
"generic-array 0.14.4",
]
[[package]]
name = "doc-comment"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10"
[[package]]
name = "dotenv"
version = "0.15.0"
@@ -675,9 +669,9 @@ dependencies = [
[[package]]
name = "instant"
version = "0.1.10"
version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bee0328b1209d157ef001c94dd85b4f8f64139adb0eac2659f4b08382b2f474d"
checksum = "716d3d89f35ac6a34fd0eed635395f4c3b76fa889338a4632e5231a8684216bd"
dependencies = [
"cfg-if",
]
@@ -711,9 +705,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libc"
version = "0.2.102"
version = "0.2.103"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2a5ac8f984bfcf3a823267e5fde638acc3325f6496633a5da6bb6eb2171e103"
checksum = "dd8f7255a17a627354f321ef0055d63b898c6fb27eff628af4d1b66b7331edf6"
[[package]]
name = "lock_api"
@@ -863,7 +857,7 @@ dependencies = [
[[package]]
name = "odin"
version = "1.4.2"
version = "1.4.3"
dependencies = [
"a2s",
"cargo-husky",
@@ -1017,9 +1011,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
[[package]]
name = "pkg-config"
version = "0.3.19"
version = "0.3.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c"
checksum = "7c9b1041b4387893b91ee6746cddfc28516aff326a3519fb2adf820932c5e6cb"
[[package]]
name = "ppv-lite86"
@@ -1401,9 +1395,9 @@ checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
[[package]]
name = "syn"
version = "1.0.76"
version = "1.0.77"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c6f107db402c2c2055242dbf4d2af0e69197202e9faacbef9571bbe47f5a1b84"
checksum = "5239bc68e0fef57495900cfea4e8dc75596d9a319d7e16b1e0a440d24e6fe0a0"
dependencies = [
"proc-macro2",
"quote",
@@ -1412,13 +1406,12 @@ dependencies = [
[[package]]
name = "sysinfo"
version = "0.18.2"
version = "0.20.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d404aefa651a24a7f2a1190fec9fb6380ba84ac511a6fefad79eb0e63d39a97d"
checksum = "92d77883450d697c0010e60db3d940ed130b0ed81d27485edee981621b434e52"
dependencies = [
"cfg-if",
"core-foundation-sys",
"doc-comment",
"libc",
"ntapi",
"once_cell",
@@ -1491,9 +1484,9 @@ dependencies = [
[[package]]
name = "tinyvec"
version = "1.4.0"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5241dd6f21443a3606b432718b166d3cedc962fd4b8bea54a8bc7f514ebda986"
checksum = "f83b2a3d4d9091d0abd7eba4dc2710b1718583bd4d8992e2190720ea38f391f7"
dependencies = [
"tinyvec_macros",
]

View File

@@ -19,7 +19,7 @@ name = "huginn"
path = "main.rs"
[dependencies]
log = "0.4.14"
log = "0.4"
tokio = { version = "1", features = ["full"] }
warp = { version = "0.3" }

View File

@@ -1,6 +1,6 @@
[package]
name = "odin"
version = "1.4.2"
version = "1.4.3"
authors = ["mbround18"]
edition = "2018"
license = "BSD-3-Clause License"
@@ -28,32 +28,32 @@ path = "lib.rs"
[dependencies]
handlebars = "4"
dotenv = "0.15.0"
log = "0.4.14"
dotenv = "0.15"
log = "0.4"
clap = { version = "2.33.3" , features = ["yaml"] }
which = "4.2.2"
serde = { version = "1.0", features = ["derive"], default_features = false }
sysinfo = { version = "0.18.2", default_features = false }
sysinfo = { version = "0.20", default_features = false }
serde_json = "1.0"
daemonize = "0.4"
tar = "0.4"
flate2 = "1.0"
inflections = "1.1.1"
md5 = "0.7.0"
reqwest = { version = "0.11.4", default_features = false, features = ["blocking", "json", "rustls-tls"] }
chrono = "0.4"
zip = { version = "0.5" }
md5 = "0.7"
reqwest = { version = "0.11", default_features = false, features = ["blocking", "json", "rustls-tls"] }
chrono = "0.4.19"
zip = { version = "0.5.13" }
fs_extra = "1.2.0"
glob = "0.3.0"
a2s = "0.4"
users = "*"
a2s = "0.4.0"
users = "0.11.0"
[dev-dependencies]
once_cell = "1.8"
rand = "0.8.4"
rand = "0.8"
serial_test = "0.5.1"
[dev-dependencies.cargo-husky]
version = "1"
version = "1.5.0"
default-features = false # Disable features which are enabled by default
features = ["run-for-all", "precommit-hook", "run-cargo-fmt", "run-cargo-test", "run-cargo-clippy"]

View File

@@ -13,20 +13,18 @@ impl ServerProcess {
}
}
pub fn get_valheim_processes(&mut self) -> Vec<&Process> {
pub fn valheim_processes(&mut self) -> Vec<&Process> {
self.system.refresh_processes();
// Limit search string to 15 characters, as some unix operating systems
// cannot handle more then 15 character long process names
let valheim_executable_search_name = &constants::VALHEIM_EXECUTABLE_NAME[..15];
self
.system
.get_process_by_name(valheim_executable_search_name)
self.system.process_by_name(valheim_executable_search_name)
}
pub fn is_running(&mut self) -> bool {
let valheim_processes = self.get_valheim_processes();
!valheim_processes.is_empty()
//noinspection RsSelfConvention
pub fn is_process_running(&mut self) -> bool {
!self.valheim_processes().is_empty()
}
}

View File

@@ -13,7 +13,7 @@ pub fn blocking_shutdown() {
pub fn send_shutdown_signal() {
info!("Scanning for Valheim process");
let mut server_process = ServerProcess::new();
let processes = server_process.get_valheim_processes();
let processes = server_process.valheim_processes();
if processes.is_empty() {
info!("Process NOT found!")
} else {
@@ -35,7 +35,7 @@ fn wait_for_exit() {
info!("Waiting for server to completely shutdown...");
let mut server_process = ServerProcess::new();
loop {
if !server_process.is_running() {
if !server_process.is_process_running() {
break;
} else {
// Delay to keep down CPU usage

View File

@@ -1,5 +1,5 @@
use super::process::ServerProcess;
pub fn is_running() -> bool {
ServerProcess::new().is_running()
ServerProcess::new().is_process_running()
}