Skip to content

Commit

Permalink
add: daemon env_vars setting
Browse files Browse the repository at this point in the history
  • Loading branch information
Nukesor committed Aug 21, 2023
1 parent 259d322 commit f9355e2
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion pueue/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
16 changes: 13 additions & 3 deletions pueue_lib/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pueue_lib/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
9 changes: 9 additions & 0 deletions pueue_lib/src/process_helper/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
3 changes: 3 additions & 0 deletions pueue_lib/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>,
/// Enironment variables that can be will be injected into all executed processes.
#[serde(default = "Default::default")]
pub env_vars: HashMap<String, String>,
/// 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,
Expand Down

0 comments on commit f9355e2

Please sign in to comment.