Compare commits

..

3 Commits

Author SHA1 Message Date
mbecker20
a07624e9b9 0.3.4 fix docker stop --signal on older docker versions 2023-05-01 21:03:25 +00:00
mbecker20
bb8054af8a log version first 2023-05-01 08:43:00 +00:00
mbecker20
7738f3e066 core logs version on startup 2023-05-01 08:34:20 +00:00
11 changed files with 70 additions and 31 deletions

44
Cargo.lock generated
View File

@@ -804,7 +804,7 @@ checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e"
[[package]]
name = "core"
version = "0.3.3"
version = "0.3.4"
dependencies = [
"anyhow",
"async_timing_util",
@@ -824,7 +824,7 @@ dependencies = [
"jwt",
"merge_config_files",
"monitor_helpers",
"monitor_types 0.3.3",
"monitor_types 0.3.4",
"mungos",
"periphery_client",
"serde",
@@ -1058,10 +1058,10 @@ checksum = "23d8666cb01533c39dde32bcbab8e227b4ed6679b2c925eba05feabea39508fb"
[[package]]
name = "db_client"
version = "0.3.3"
version = "0.3.4"
dependencies = [
"anyhow",
"monitor_types 0.3.3",
"monitor_types 0.3.4",
"mungos",
]
@@ -1934,14 +1934,14 @@ dependencies = [
[[package]]
name = "monitor_cli"
version = "0.3.3"
version = "0.3.4"
dependencies = [
"async_timing_util",
"clap",
"colored",
"monitor_types 0.3.3",
"monitor_types 0.3.4",
"rand",
"run_command",
"run_command 0.0.5",
"serde",
"serde_derive",
"strum",
@@ -1951,12 +1951,12 @@ dependencies = [
[[package]]
name = "monitor_client"
version = "0.3.3"
version = "0.3.4"
dependencies = [
"anyhow",
"envy",
"futures-util",
"monitor_types 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"monitor_types 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
"reqwest",
"serde",
"serde_derive",
@@ -1968,11 +1968,11 @@ dependencies = [
[[package]]
name = "monitor_helpers"
version = "0.3.3"
version = "0.3.4"
dependencies = [
"anyhow",
"axum",
"monitor_types 0.3.3",
"monitor_types 0.3.4",
"rand",
"serde",
"serde_json",
@@ -1981,7 +1981,7 @@ dependencies = [
[[package]]
name = "monitor_periphery"
version = "0.3.3"
version = "0.3.4"
dependencies = [
"anyhow",
"async_timing_util",
@@ -1994,9 +1994,9 @@ dependencies = [
"futures",
"merge_config_files",
"monitor_helpers",
"monitor_types 0.3.3",
"monitor_types 0.3.4",
"parse_csl",
"run_command",
"run_command 0.0.6",
"serde",
"serde_derive",
"serde_json",
@@ -2009,7 +2009,7 @@ dependencies = [
[[package]]
name = "monitor_types"
version = "0.3.3"
version = "0.3.4"
dependencies = [
"anyhow",
"bollard",
@@ -2026,9 +2026,9 @@ dependencies = [
[[package]]
name = "monitor_types"
version = "0.3.3"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "812da979965797618e2eb338da005a5ec2658d621f17af2cf26d15be3b2ff59e"
checksum = "24ce7541ee0fad1452ae11d0db73285cfbb9df79ad3e49c0680d0bc27c64db24"
dependencies = [
"anyhow",
"bollard",
@@ -2275,11 +2275,11 @@ checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e"
[[package]]
name = "periphery_client"
version = "0.3.3"
version = "0.3.4"
dependencies = [
"anyhow",
"futures-util",
"monitor_types 0.3.3",
"monitor_types 0.3.4",
"reqwest",
"serde",
"serde_json",
@@ -2500,6 +2500,12 @@ name = "run_command"
version = "0.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb00d9c9c67906454ba83e62aaa52368814512ac1c5b65b8791bb313a9257b0e"
[[package]]
name = "run_command"
version = "0.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "388e1106aa4bd809ba57afecb8b3efc60b6599cd06a774d5798a7c5a29675307"
dependencies = [
"tokio",
]

View File

@@ -1,6 +1,6 @@
[package]
name = "monitor_cli"
version = "0.3.3"
version = "0.3.4"
edition = "2021"
authors = ["MoghTech"]
description = "monitor cli | tools to setup monitor system"

View File

@@ -1,6 +1,6 @@
[package]
name = "core"
version = "0.3.3"
version = "0.3.4"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@@ -20,6 +20,8 @@ type ResponseResult<T> = Result<T, (StatusCode, String)>;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
println!("version: v{}", env!("CARGO_PKG_VERSION"));
let (config, spa_router) = config::load();
println!("starting monitor core on port {}...", config.port);

View File

@@ -1,6 +1,6 @@
[package]
name = "db_client"
version = "0.3.3"
version = "0.3.4"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@@ -1,6 +1,6 @@
[package]
name = "monitor_helpers"
version = "0.3.3"
version = "0.3.4"
edition = "2021"
authors = ["MoghTech"]
description = "helpers used as dependency for mogh tech monitor"

View File

@@ -1,6 +1,6 @@
[package]
name = "monitor_client"
version = "0.3.3"
version = "0.3.4"
edition = "2021"
authors = ["MoghTech"]
description = "a client to interact with the monitor system"
@@ -9,7 +9,7 @@ license = "GPL-3.0-or-later"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
monitor_types = "0.3.3"
monitor_types = "0.3.4"
# monitor_types = { path = "../types" }
reqwest = { version = "0.11", features = ["json"] }
tokio-tungstenite = { version = "0.18", features=["native-tls"] }

View File

@@ -1,6 +1,6 @@
[package]
name = "periphery_client"
version = "0.3.3"
version = "0.3.4"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@@ -1,6 +1,6 @@
[package]
name = "monitor_types"
version = "0.3.3"
version = "0.3.4"
edition = "2021"
authors = ["MoghTech"]
description = "types for the mogh tech monitor"

View File

@@ -1,6 +1,6 @@
[package]
name = "monitor_periphery"
version = "0.3.3"
version = "0.3.4"
edition = "2021"
authors = ["MoghTech"]
description = "monitor periphery binary"
@@ -15,7 +15,7 @@ path = "src/main.rs"
[dependencies]
helpers = { package = "monitor_helpers", path = "../lib/helpers" }
types = { package = "monitor_types", path = "../lib/types" }
run_command = { version = "0.0.5", features = ["async_tokio"] }
run_command = { version = "0.0.6", features = ["async_tokio"] }
async_timing_util = "0.1.14"
tokio = { version = "1.26", features = ["full"] }
axum = { version = "0.6", features = ["ws"] }

View File

@@ -64,7 +64,22 @@ pub async fn stop_container(
time: Option<i32>,
) -> Log {
let command = stop_container_command(container_name, signal, time);
run_monitor_command("docker stop", command).await
let log = run_monitor_command("docker stop", command).await;
if log.stderr.contains("unknown flag: --signal") {
let command = stop_container_command(container_name, None, time);
let mut log = run_monitor_command("docker stop", command).await;
log.stderr = format!(
"old docker version: unable to use --signal flag{}",
if log.stderr.len() > 0 {
format!("\n\n{}", log.stderr)
} else {
String::new()
}
);
log
} else {
log
}
}
pub async fn stop_and_remove_container(
@@ -74,7 +89,23 @@ pub async fn stop_and_remove_container(
) -> Log {
let stop_command = stop_container_command(container_name, signal, time);
let command = format!("{stop_command} && docker container rm {container_name}");
run_monitor_command("docker stop and remove", command).await
let log = run_monitor_command("docker stop and remove", command).await;
if log.stderr.contains("unknown flag: --signal") {
let stop_command = stop_container_command(container_name, None, time);
let command = format!("{stop_command} && docker container rm {container_name}");
let mut log = run_monitor_command("docker stop", command).await;
log.stderr = format!(
"old docker version: unable to use --signal flag{}",
if log.stderr.len() > 0 {
format!("\n\n{}", log.stderr)
} else {
String::new()
}
);
log
} else {
log
}
}
fn stop_container_command(