From d16dd6de7b1ce02832965a42fe689a61197ee579 Mon Sep 17 00:00:00 2001 From: Max Date: Sat, 9 Nov 2024 16:57:54 +0100 Subject: [PATCH] cluster/services/ways: only reload nginx if actually running --- cluster/services/ways/host.nix | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cluster/services/ways/host.nix b/cluster/services/ways/host.nix index 90455c3..984d55c 100644 --- a/cluster/services/ways/host.nix +++ b/cluster/services/ways/host.nix @@ -89,11 +89,11 @@ in '') consulServiceWays; in pkgs.writeText "ways-upstreams.ctmpl" (lib.concatStringsSep "\n" (lib.unique upstreams)); destination = "/run/consul-template/nginx-ways-upstreams.conf"; - exec.command = [ - "${config.services.nginx.package}/bin/nginx" - "-s" "reload" - "-g" "pid /run/nginx/nginx.pid;" - ]; + exec.command = lib.singleton (pkgs.writeShellScript "ways-reload" '' + if ${config.systemd.package}/bin/systemctl is-active nginx.service; then + exec ${config.services.nginx.package}/bin/nginx -s reload -g 'pid /run/nginx/nginx.pid;' + fi + ''); } ]; };