about summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorembr <git@liclac.eu>2021-09-04 11:07:04 +0200
committerKerstin <kerstin@erictapen.name>2021-09-21 16:35:17 +0200
commit023239912cb60ffa5d8754ccaa867f2b0bce5c0a (patch)
treecb4609f843ab45f48dc114342af1cea7706fa5da /nixos
parent8c1e6a8598a34107d27444219778f55b1ba45ff4 (diff)
downloadnixlib-023239912cb60ffa5d8754ccaa867f2b0bce5c0a.tar
nixlib-023239912cb60ffa5d8754ccaa867f2b0bce5c0a.tar.gz
nixlib-023239912cb60ffa5d8754ccaa867f2b0bce5c0a.tar.bz2
nixlib-023239912cb60ffa5d8754ccaa867f2b0bce5c0a.tar.lz
nixlib-023239912cb60ffa5d8754ccaa867f2b0bce5c0a.tar.xz
nixlib-023239912cb60ffa5d8754ccaa867f2b0bce5c0a.tar.zst
nixlib-023239912cb60ffa5d8754ccaa867f2b0bce5c0a.zip
nixos/mastodon: Add configurable web- and streaming concurrency
Might as well do this while I'm at it.
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/services/web-apps/mastodon.nix25
1 files changed, 25 insertions, 0 deletions
diff --git a/nixos/modules/services/web-apps/mastodon.nix b/nixos/modules/services/web-apps/mastodon.nix
index e3bc70791cfb..5bda7d5a5dd2 100644
--- a/nixos/modules/services/web-apps/mastodon.nix
+++ b/nixos/modules/services/web-apps/mastodon.nix
@@ -9,6 +9,13 @@ let
     RAILS_ENV = "production";
     NODE_ENV = "production";
 
+    # mastodon-web concurrency.
+    WEB_CONCURRENCY = toString cfg.webProcesses;
+    MAX_THREADS = toString cfg.webThreads;
+
+    # mastodon-streaming concurrency.
+    STREAMING_CLUSTER_NUM = toString cfg.streamingProcesses;
+
     DB_USER = cfg.database.user;
 
     REDIS_HOST = cfg.redis.host;
@@ -146,12 +153,30 @@ in {
         type = lib.types.port;
         default = 55000;
       };
+      streamingProcesses = lib.mkOption {
+        description = ''
+          Processes used by the mastodon-streaming service.
+          Defaults to the number of CPU cores minus one.
+        '';
+        type = lib.types.nullOr lib.types.int;
+        default = null;
+      };
 
       webPort = lib.mkOption {
         description = "TCP port used by the mastodon-web service.";
         type = lib.types.port;
         default = 55001;
       };
+      webProcesses = lib.mkOption {
+        description = "Processes used by the mastodon-web service.";
+        type = lib.types.int;
+        default = 2;
+      };
+      webThreads = lib.mkOption {
+        description = "Threads per process used by the mastodon-web service.";
+        type = lib.types.int;
+        default = 5;
+      };
 
       sidekiqPort = lib.mkOption {
         description = "TCP port used by the mastodon-sidekiq service.";