nixos/nats: Implemented configuration verification

This commit is contained in:
Jonathan Davies 2024-06-23 21:54:04 +01:00
parent 2789cee804
commit 5ea0207b73
No known key found for this signature in database

View File

@ -10,6 +10,13 @@ let
configFile = format.generate "nats.conf" cfg.settings; configFile = format.generate "nats.conf" cfg.settings;
validateConfig = file:
pkgs.runCommand "validate-nats-conf" {
nativeBuildInputs = [ pkgs.nats-server ];
} ''
nats-server --config "${configFile}" -t
ln -s "${configFile}" "$out"
'';
in { in {
### Interface ### Interface
@ -104,7 +111,7 @@ in {
}) })
{ {
Type = "simple"; Type = "simple";
ExecStart = "${pkgs.nats-server}/bin/nats-server -c ${configFile}"; ExecStart = "${pkgs.nats-server}/bin/nats-server -c ${validateConfig configFile}";
ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID"; ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
ExecStop = "${pkgs.coreutils}/bin/kill -SIGINT $MAINPID"; ExecStop = "${pkgs.coreutils}/bin/kill -SIGINT $MAINPID";
Restart = "on-failure"; Restart = "on-failure";