From 10895f6feaf74737da0b2b5629f9d754542b4e6d Mon Sep 17 00:00:00 2001 From: D Anzorge Date: Mon, 12 Apr 2021 21:47:15 +0200 Subject: [PATCH] Nix module: make systemd units wait for redis/postges conditionally If createLocally is not set, do not wait for the units, in case they're not actually on current server. --- nix/module.nix | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/nix/module.nix b/nix/module.nix index 3c63729be..6834c6279 100644 --- a/nix/module.nix +++ b/nix/module.nix @@ -39,6 +39,8 @@ let EMAIL_HOST_PASSWORD = cfg.email.passwordFile; }); + redisCreateLocally = cfg.celeryRedis.createLocally || cfg.activityRedis.createLocally; + loadEnv = (pkgs.writeScript "load-bookwyrm-env" '' #!/usr/bin/env bash ${lib.concatStringsSep "\n" (lib.mapAttrsToList (n: v: "export ${n}='${v}'") env)} @@ -368,12 +370,12 @@ in "redis.service" "postgresql.service" "bookwyrm-celery.service" - ]; + ] ++ optional redisCreateLocally "redis.service" + ++ optional cfg.database.createLocally "postgresql.service"; bindsTo = [ - "redis.service" - "postgresql.service" "bookwyrm-celery.service" - ]; + ] ++ optional redisCreateLocally "redis.service" + ++ optional cfg.database.createLocally "postgresql.service"; wantedBy = [ "bookwyrm.target" ]; partOf = [ "bookwyrm.target" ]; environment = env; @@ -403,9 +405,8 @@ in description = "Celery service for bookwyrm."; after = [ "network.target" - "redis.service" - ]; - bindsTo = [ + ] ++ optional redisCreateLocally "redis.service"; + bindsTo = optionals redisCreateLocally [ "redis.service" ]; wantedBy = [ "bookwyrm.target" ]; @@ -432,8 +433,8 @@ in "network.target" "redis.service" "bookwyrm-celery.service" - ]; - bindsTo = [ + ] ++ optional redisCreateLocally "redis.service"; + bindsTo = optionals redisCreateLocally [ "redis.service" ]; wantedBy = [ "bookwyrm.target" ];