Skip to content

Commit

Permalink
First step for cron jobs in zinit
Browse files Browse the repository at this point in the history
  • Loading branch information
maximevanhees committed Oct 3, 2024
1 parent 367cc28 commit b24270f
Show file tree
Hide file tree
Showing 4 changed files with 276 additions and 119 deletions.
136 changes: 123 additions & 13 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ thiserror = "1.0"
clap = "2.33"
git-version = "0.3.5"
command-group = "1.0.8"
futures = "0.3.30"
11 changes: 11 additions & 0 deletions src/zinit/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ pub struct Service {
pub log: Log,
pub env: HashMap<String, String>,
pub dir: String,
pub cron: Option<u64>,
}

impl Service {
Expand All @@ -64,6 +65,16 @@ impl Service {

Signal::from_str(&self.signal.stop.to_uppercase())?;

// Validate the cron field if present
if let Some(cron_value) = self.cron {
if cron_value == 0 {
bail!("cron value must be greater than zero");
}
if !self.one_shot {
bail!("cron can only be specified for oneshot services");
}
}

Ok(())
}
}
Expand Down
Loading

0 comments on commit b24270f

Please sign in to comment.