From be81a9d20756e9f2b7c369ade42137682608b8b3 Mon Sep 17 00:00:00 2001 From: Mikhail Klementev Date: Fri, 14 Apr 2023 19:03:56 +0000 Subject: [PATCH] Migration to upstream mastodon.nix queues definitions --- disable-services.nix | 2 +- mastodon.nix | 40 ++++++++++++---------------------------- 2 files changed, 13 insertions(+), 29 deletions(-) diff --git a/disable-services.nix b/disable-services.nix index 1ec45d7..7ff0c73 100644 --- a/disable-services.nix +++ b/disable-services.nix @@ -5,7 +5,7 @@ systemd.services."mastodon-init-dirs".wantedBy = lib.mkForce [ ]; systemd.services."mastodon-media-auto-remove".startAt = lib.mkForce [ ]; systemd.services."mastodon-media-auto-remove".wantedBy = lib.mkForce [ ]; - systemd.services."mastodon-sidekiq".wantedBy = lib.mkForce [ ]; + systemd.services."mastodon-sidekiq-all".wantedBy = lib.mkForce [ ]; systemd.services."mastodon-streaming".wantedBy = lib.mkForce [ ]; systemd.services."mastodon-web".wantedBy = lib.mkForce [ ]; systemd.services."postgresqlBackup-mastodon".startAt = lib.mkForce [ ]; diff --git a/mastodon.nix b/mastodon.nix index ab865f2..44f4499 100644 --- a/mastodon.nix +++ b/mastodon.nix @@ -34,29 +34,6 @@ let }; }; - sidekiq-manager = pkgs.writers.writePython3 "sidekiq-manager" {} '' - from itertools import permutations - from subprocess import Popen - - - def sidekiq(queues, connections=16): - mastodon = "${mastodon-lor-sh}" - cmd = [f"{mastodon}/bin/sidekiq", "-r", mastodon] - cmd += ["-c", f"{connections}"] - for q in queues: - cmd += ['-q', q] - return Popen(cmd) - - - procs = [sidekiq(['mailers', 'pull', 'scheduler'])] - - queues = ['default', 'push', 'ingress'] - procs += [sidekiq(qs) for qs in permutations(queues)] - - p = sidekiq([]) - p.wait() - ''; - s3cmd = pkgs.writeShellScript "s3cmd" '' ${pkgs.s3cmd}/bin/s3cmd \ --access_key='${secrets.backup.accessKey}' \ @@ -114,12 +91,8 @@ in { rm mastodon.sql.gz.gpg ''; - # Until merge of https://github.com/NixOS/nixpkgs/pull/202408 - systemd.services.mastodon-sidekiq.serviceConfig.ExecStart = - lib.mkForce "${sidekiq-manager}"; - # https://github.com/mperham/sidekiq/wiki/Memory#bloat - systemd.services.mastodon-sidekiq.environment.MALLOC_ARENA_MAX = "2"; + systemd.services.mastodon-sidekiq-all.environment.MALLOC_ARENA_MAX = "2"; services.caddy = { enable = true; @@ -195,5 +168,16 @@ in { DEEPL_API_KEY = secrets.DEEPL_API_KEY; DEEPL_PLAN = "pro"; }; + + sidekiqProcesses = { + all = { jobClasses = [ ]; threads = null; }; + a = { jobClasses = [ "mailers" "pull" "scheduler" ]; threads = null; }; + b = { jobClasses = [ "default" "push" "ingress" ]; threads = null; }; + c = { jobClasses = [ "default" "ingress" "push" ]; threads = null; }; + d = { jobClasses = [ "push" "default" "ingress" ]; threads = null; }; + e = { jobClasses = [ "push" "ingress" "default" ]; threads = null; }; + f = { jobClasses = [ "ingress" "default" "push" ]; threads = null; }; + g = { jobClasses = [ "ingress" "push" "default" ]; threads = null; }; + }; }; }