mirror of
https://github.com/CHN-beta/nixpkgs.git
synced 2026-01-11 10:22:54 +08:00
[Backport release-25.05] nixos/vector: add graceful shutdown limit option; nixos/vector: add option to disable the configuration validation (#428623)
This commit is contained in:
@@ -6,7 +6,6 @@
|
||||
}:
|
||||
let
|
||||
cfg = config.services.vector;
|
||||
|
||||
in
|
||||
{
|
||||
options.services.vector = {
|
||||
@@ -22,6 +21,23 @@ in
|
||||
'';
|
||||
};
|
||||
|
||||
gracefulShutdownLimitSecs = lib.mkOption {
|
||||
type = lib.types.ints.positive;
|
||||
default = 60;
|
||||
description = ''
|
||||
Set the duration in seconds to wait for graceful shutdown after SIGINT or SIGTERM are received.
|
||||
After the duration has passed, Vector will force shutdown.
|
||||
'';
|
||||
};
|
||||
|
||||
validateConfig = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = true;
|
||||
description = ''
|
||||
Enable the checking of the vector config during build time. This should be disabled when interpolating environment variables.
|
||||
'';
|
||||
};
|
||||
|
||||
settings = lib.mkOption {
|
||||
type = (pkgs.formats.json { }).type;
|
||||
default = { };
|
||||
@@ -44,7 +60,7 @@ in
|
||||
let
|
||||
format = pkgs.formats.toml { };
|
||||
conf = format.generate "vector.toml" cfg.settings;
|
||||
validateConfig =
|
||||
validatedConfig =
|
||||
file:
|
||||
pkgs.runCommand "validate-vector-conf"
|
||||
{
|
||||
@@ -56,7 +72,9 @@ in
|
||||
'';
|
||||
in
|
||||
{
|
||||
ExecStart = "${lib.getExe cfg.package} --config ${validateConfig conf}";
|
||||
ExecStart = "${lib.getExe cfg.package} --config ${
|
||||
if cfg.validateConfig then (validatedConfig conf) else conf
|
||||
} --graceful-shutdown-limit-secs ${builtins.toString cfg.gracefulShutdownLimitSecs}";
|
||||
DynamicUser = true;
|
||||
Restart = "always";
|
||||
StateDirectory = "vector";
|
||||
|
||||
Reference in New Issue
Block a user