From 4f8927c417df17c1eaf0a6fe5d84f14ebc08f56a Mon Sep 17 00:00:00 2001 From: embr Date: Sat, 4 Sep 2021 10:53:09 +0200 Subject: [PATCH] nixos/mastodon: Fix sidekiq's DB_POOL, add configurable concurrency The `services.mastodon` module currently hardcodes sidekiq's concurrency to 25, but doesn't set a DB pool size, which defaults to 5 or the number of configured web threads. (This behaviour is very strange, and arguably a mastodon bug.) This also makes sidekiq's concurrency configurable, because 25 is a tad high for the hardware I'm running it on. (cherry picked from commit e8fd7792d1eeb4ea4943cc34525da1159ab50bc9) --- nixos/modules/services/web-apps/mastodon.nix | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/nixos/modules/services/web-apps/mastodon.nix b/nixos/modules/services/web-apps/mastodon.nix index 5e24bd06ffd..e3bc70791cf 100644 --- a/nixos/modules/services/web-apps/mastodon.nix +++ b/nixos/modules/services/web-apps/mastodon.nix @@ -154,10 +154,15 @@ in { }; sidekiqPort = lib.mkOption { - description = "TCP port used by the mastodon-sidekiq service"; + description = "TCP port used by the mastodon-sidekiq service."; type = lib.types.port; default = 55002; }; + sidekiqThreads = lib.mkOption { + description = "Worker threads used by the mastodon-sidekiq service."; + type = lib.types.int; + default = 25; + }; vapidPublicKeyFile = lib.mkOption { description = '' @@ -524,9 +529,10 @@ in { wantedBy = [ "multi-user.target" ]; environment = env // { PORT = toString(cfg.sidekiqPort); + DB_POOL = toString cfg.sidekiqThreads; }; serviceConfig = { - ExecStart = "${cfg.package}/bin/sidekiq -c 25 -r ${cfg.package}"; + ExecStart = "${cfg.package}/bin/sidekiq -c ${toString cfg.sidekiqThreads} -r ${cfg.package}"; Restart = "always"; RestartSec = 20; EnvironmentFile = "/var/lib/mastodon/.secrets_env";