Skip to content

Commit

Permalink
deadman's switch
Browse files Browse the repository at this point in the history
  • Loading branch information
bertiqwerty committed Oct 12, 2024
1 parent 2c9332c commit df18212
Show file tree
Hide file tree
Showing 6 changed files with 206 additions and 32 deletions.
90 changes: 90 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion rvimage/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ serde_json = "1.0.128"
ssh2 = { version = "0.9.4", features = ["vendored-openssl"] }
toml = "0.8.19"
walkdir = "2.5"
tokio = { version = "1.40.0", optional = true, features = ["rt-multi-thread"]}
tokio = { version = "1.40.0", optional = true, features = ["rt-multi-thread"] }
uuid = { version = "1.10.0", features = ["v4", "fast-rng"] }
exmex = "0.20.3"
tracing = "0.1.40"
Expand All @@ -69,3 +69,5 @@ backtrace = "0.3.74"
zip = "2.2.0"
rvimage-domain = "0.4.5"
clap = { version = "4.5.19", features = ["derive"] }
chrono = { version = "0.4.38", features = ["serde"] }
whoami = "1.5.2"
8 changes: 8 additions & 0 deletions rvimage/src/rvlib/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::{
sort_params::SortParams,
ssh,
};
use chrono::{DateTime, Utc};
use rvimage_domain::{rverr, to_rv, RvError, RvResult};
use serde::{de::DeserializeOwned, Deserialize, Serialize};
use std::{
Expand Down Expand Up @@ -76,6 +77,7 @@ impl CfgLegacy {
prefix: ab.prefix,
}),
sort_params: SortParams::default(),
deadmansswitch: Utc::now(),
};
Cfg { usr, prj }
}
Expand Down Expand Up @@ -339,6 +341,8 @@ pub struct CfgPrj {
pub azure_blob: Option<AzureBlobCfgPrj>,
#[serde(default)]
pub sort_params: SortParams,
#[serde(default = "Utc::now")]
pub deadmansswitch: DateTime<Utc>,
}
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq, Default)]
pub struct Cfg {
Expand Down Expand Up @@ -370,6 +374,10 @@ impl Cfg {
}
}

pub fn push_deadmansswitch(&mut self) {
self.prj.deadmansswitch = Utc::now();
}

pub fn tmpdir(&self) -> &str {
match &self.usr.tmpdir {
Some(td) => td.as_str(),
Expand Down
Loading

0 comments on commit df18212

Please sign in to comment.