From f9355e23dd9a24673666c74a7e49d1dbb96fea70 Mon Sep 17 00:00:00 2001 From: Arne Beer Date: Mon, 21 Aug 2023 23:08:20 +0200 Subject: [PATCH] add: daemon env_vars setting --- CHANGELOG.md | 1 + Cargo.lock | 2 +- pueue/Cargo.toml | 2 +- pueue_lib/CHANGELOG.md | 16 +++++++++++++--- pueue_lib/Cargo.toml | 2 +- pueue_lib/src/process_helper/mod.rs | 9 +++++++++ pueue_lib/src/settings.rs | 3 +++ 7 files changed, 29 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5935562d..df401309 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Added - Allow configuration of the shell command that executes task commands. [#454](https://github.com/Nukesor/pueue/issues/454) +- Allow injection of hard coded environment variables via config file. [#454](https://github.com/Nukesor/pueue/issues/454) ## [3.2.0] - 2023-06-13 diff --git a/Cargo.lock b/Cargo.lock index 90578688..dcedbe83 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1247,7 +1247,7 @@ dependencies = [ [[package]] name = "pueue-lib" -version = "0.23.0" +version = "0.24.0" dependencies = [ "anyhow", "async-trait", diff --git a/pueue/Cargo.toml b/pueue/Cargo.toml index 5c782c0d..0bb6e56a 100644 --- a/pueue/Cargo.toml +++ b/pueue/Cargo.toml @@ -15,7 +15,7 @@ rust-version.workspace = true maintenance = { status = "actively-developed" } [dependencies] -pueue-lib = { version = "0.23.0", path = "../pueue_lib" } +pueue-lib = { version = "0.24.0", path = "../pueue_lib" } anyhow = "1.0" chrono-english = "0.1" diff --git a/pueue_lib/CHANGELOG.md b/pueue_lib/CHANGELOG.md index a679fc9d..63f808e5 100644 --- a/pueue_lib/CHANGELOG.md +++ b/pueue_lib/CHANGELOG.md @@ -6,19 +6,29 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). This project adheres **somewhat** to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). The concept of SemVer is applied to the daemon/client API, but not the library API itself. -## [0.23.0] - unreleased +## [0.24.0] - 2023-06-13 + +### Added + +- New setting `daemon.shell_command` to configure how the command shall be executed. +- New setting `daemon.env_vars` to inject hard coded environment variables into the process. ### Changed - Refactor `State::filter_*` functions to return proper type. -## [0.22.0] - 2023-06-13 +## [0.23.0] - 2023-06-13 -## Added +### Added - Add `priority` field to `Task` - Remove `tempdir` dependency +## [0.22.0] + +This version was skipped due to a error during release :). + + ## [0.21.3] - 2023-02-12 ### Changed diff --git a/pueue_lib/Cargo.toml b/pueue_lib/Cargo.toml index b76c20f1..30803ab2 100644 --- a/pueue_lib/Cargo.toml +++ b/pueue_lib/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pueue-lib" -version = "0.23.0" +version = "0.24.0" description = "The shared library to work with the Pueue client and daemon." keywords = ["pueue"] readme = "README.md" diff --git a/pueue_lib/src/process_helper/mod.rs b/pueue_lib/src/process_helper/mod.rs index c51a8b9f..e097580a 100644 --- a/pueue_lib/src/process_helper/mod.rs +++ b/pueue_lib/src/process_helper/mod.rs @@ -99,5 +99,14 @@ pub fn compile_shell_command(settings: &Settings, command: &str) -> Command { command.arg(&arg); } + // Inject custom environment variables. + if !settings.daemon.env_vars.is_empty() { + log::info!( + "Inject environment variables: {:?}", + &settings.daemon.env_vars + ); + command.envs(&settings.daemon.env_vars); + } + command } diff --git a/pueue_lib/src/settings.rs b/pueue_lib/src/settings.rs index 4f069b33..544663eb 100644 --- a/pueue_lib/src/settings.rs +++ b/pueue_lib/src/settings.rs @@ -116,6 +116,9 @@ pub struct Daemon { pub pause_all_on_failure: bool, /// The callback that's called whenever a task finishes. pub callback: Option, + /// Enironment variables that can be will be injected into all executed processes. + #[serde(default = "Default::default")] + pub env_vars: HashMap, /// The amount of log lines from stdout/stderr that are passed to the callback command. #[serde(default = "default_callback_log_lines")] pub callback_log_lines: usize,