summary refs log tree commit diff
path: root/host/Rory-nginx/services/matrix/synapse/workers/sync.nix
diff options
context:
space:
mode:
Diffstat (limited to 'host/Rory-nginx/services/matrix/synapse/workers/sync.nix')
-rw-r--r--host/Rory-nginx/services/matrix/synapse/workers/sync.nix26
1 files changed, 11 insertions, 15 deletions
diff --git a/host/Rory-nginx/services/matrix/synapse/workers/sync.nix b/host/Rory-nginx/services/matrix/synapse/workers/sync.nix
index b9ccad3..579e14b 100644
--- a/host/Rory-nginx/services/matrix/synapse/workers/sync.nix
+++ b/host/Rory-nginx/services/matrix/synapse/workers/sync.nix
@@ -1,13 +1,9 @@
-{
-  config,
-  pkgs,
-  lib,
-  ...
-}:
+{ config, lib, ... }:
 
 let
   cfg = config.services.matrix-synapse;
   workers = lib.range 0 (cfg.syncWorkers - 1);
+  workerName = "sync";
   routes = [
     "~ ^/_matrix/client/(v2_alpha|r0|v3)/sync$"
     "~ ^/_matrix/client/(api/v1|v2_alpha|r0|v3)/events$"
@@ -21,9 +17,9 @@ in
       settings = {
         instance_map = lib.listToAttrs (
           lib.map (index: {
-            name = "sync-${toString index}";
+            name = "${workerName}-${toString index}";
             value = {
-              path = "/run/matrix-synapse/sync-${toString index}.sock";
+              path = "/run/matrix-synapse/${workerName}-${toString index}.sock";
             };
           }) workers
         );
@@ -31,13 +27,13 @@ in
 
       workers = lib.listToAttrs (
         lib.map (index: {
-          name = "sync-${toString index}";
+          name = "${workerName}-${toString index}";
           value = {
             worker_app = "synapse.app.generic_worker";
             worker_listeners = [
               {
                 type = "http";
-                path = "/run/matrix-synapse/sync-${toString index}.sock";
+                path = "/run/matrix-synapse/${workerName}-${toString index}.sock";
                 resources = [
                   {
                     names = [ "replication" ];
@@ -47,7 +43,7 @@ in
               }
               {
                 type = "http";
-                path = "/run/matrix-synapse/sync-client-${toString index}.sock";
+                path = "/run/matrix-synapse/${workerName}-client-${toString index}.sock";
                 mode = "666";
                 resources = [
                   {
@@ -59,7 +55,7 @@ in
             ];
             database = (
               import ../db.nix {
-                workerName = "sync-${toString index}";
+                workerName = "${workerName}-${toString index}";
                 dbGroup = "small";
               }
             );
@@ -68,13 +64,13 @@ in
       );
     };
 
-    services.nginx.upstreams."sync" = {
+    services.nginx.upstreams."${workerName}" = {
       extraConfig = ''
         keepalive 32;
       '';
       servers = lib.listToAttrs (
         lib.map (index: {
-          name = "unix:/run/matrix-synapse/sync-client-${toString index}.sock";
+          name = "unix:/run/matrix-synapse/${workerName}-client-${toString index}.sock";
           value = {
             max_fails = 0;
           };
@@ -86,7 +82,7 @@ in
       lib.map (route: {
         name = route;
         value = {
-          proxyPass = "http://sync";
+          proxyPass = "http://${workerName}";
         };
       }) routes
     );