Skip to content

nixos/mastodon: Allow configuring sidekiq processes #202408

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

vivlim
Copy link
Contributor

@vivlim vivlim commented Nov 22, 2022

This change allows the number of sidekiq processes and which job classes they handle to be configured.

An instance admin may choose to have separate sidekiq processes handling jobs related to local users (default job class) and jobs related to federation (push, pull, ingress), so that as the instance grows and takes on more federation traffic, the local users' experience is not as impacted.

For more details, see https://docs.joinmastodon.org/admin/scaling/#sidekiq

Description of changes

I added a config setting to allow users to define any number of sidekiq processes that they want to run in separate systemd units.

As a side effect, the sidekiq unit started by the default config was renamed from mastodon-sidekiq to mastodon-sidekiq-all. I updated the related test to match. Let me know if you have a preference for the base unit to not be renamed, and if you have any suggestions on idiomatic ways to to derive its name from an empty string key without appending a trailing -.

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 22.11 Release Notes (or backporting 22.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

@github-actions github-actions bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` labels Nov 22, 2022
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 labels Nov 22, 2022
Copy link
Member

@teutat3s teutat3s left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, this will probably come in handy with the recent wave of new users on mastodon. Two small suggestions, LGTM otherwise. Didn't test this on real hardware though.

@vivlim
Copy link
Contributor Author

vivlim commented Nov 22, 2022

this definitely came in handy for me already - I needed to scale up sidekiq on a larger instance that had the local timeline behind by ~5-8 hours, and while increasing raw thread count would have helped, being able to have dedicated processes for local users and federation worked great.

without this change, it's pretty hard to spin up additional sidekiq processes adhoc to handle specific queues; several job classes need imagemagick and ffmpeg so you have to make sure those are available etc. all stuff that's already handled in the systemd unit

@vivlim
Copy link
Contributor Author

vivlim commented Nov 22, 2022

tests failed after the 2nd last push, sidekiq's getting called with malformed args. investigating

Copy link
Member

@teutat3s teutat3s left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, test is green here.

@vivlim
Copy link
Contributor Author

vivlim commented Nov 23, 2022

came back green for me too, I had forgotten to use the new threads variable in the unit definition.

thanks!

@vivlim
Copy link
Contributor Author

vivlim commented Nov 23, 2022

is there anything else I need to do before this can be merged? this is my first time opening a pr against nixpkgs, so I'm not sure if there's a step I missed.

@Izorkin
Copy link
Contributor

Izorkin commented Nov 23, 2022

Can you change ID in systemd logs? Example:

diff --git a/nixos/modules/services/web-apps/mastodon.nix b/nixos/modules/services/web-apps/mastodon.nix
index 87079922a38..020a056a3a4 100644
--- a/nixos/modules/services/web-apps/mastodon.nix
+++ b/nixos/modules/services/web-apps/mastodon.nix
@@ -105,7 +105,7 @@ let
   sidekiqUnits = lib.attrsets.mapAttrs' (name: processCfg:
     lib.nameValuePair "mastodon-sidekiq-${name}" (let
       jobClassArgs = lib.concatStringsSep " " (builtins.map (c: "-q ${c}") processCfg.jobClasses);
-      jobClassLabel = lib.concatStringsSep " " ([""] ++ processCfg.jobClasses);
+      jobClassLabel = lib.concatStringsSep "-" ([""] ++ processCfg.jobClasses);
       threads = toString (if processCfg.threads == null then cfg.sidekiqThreads else processCfg.threads);
     in {
       after = [ "network.target" "mastodon-init-dirs.service" ]
@@ -126,6 +126,7 @@ let
         RestartSec = 20;
         EnvironmentFile = "/var/lib/mastodon/.secrets_env";
         WorkingDirectory = cfg.package;
+        SyslogIdentifier = "mastodon-sidekiq${jobClassLabel}";
         # System Call Filtering
         SystemCallFilter = [ ("~" + lib.concatStringsSep " " systemCallsList) "@chown" "pipe" "pipe2" ];
       } // cfgService;
@@ -618,6 +619,7 @@ in {
       serviceConfig = {
         Type = "oneshot";
         WorkingDirectory = cfg.package;
+        SyslogIdentifier = "mastodon-init-dirs";
         # System Call Filtering
         SystemCallFilter = [ ("~" + lib.concatStringsSep " " (systemCallsList ++ [ "@resources" ])) "@chown" "pipe" "pipe2" ];
       } // cfgService;
@@ -662,6 +664,7 @@ in {
         Type = "oneshot";
         EnvironmentFile = "/var/lib/mastodon/.secrets_env";
         WorkingDirectory = cfg.package;
+        SyslogIdentifier = "mastodon-init-db";
         # System Call Filtering
         SystemCallFilter = [ ("~" + lib.concatStringsSep " " (systemCallsList ++ [ "@resources" ])) "@chown" "pipe" "pipe2" ];
       } // cfgService;
@@ -690,6 +693,7 @@ in {
         RestartSec = 20;
         EnvironmentFile = "/var/lib/mastodon/.secrets_env";
         WorkingDirectory = cfg.package;
+        SyslogIdentifier = "mastodon-streaming";
         # Runtime directory and mode
         RuntimeDirectory = "mastodon-streaming";
         RuntimeDirectoryMode = "0750";
@@ -717,6 +721,7 @@ in {
         RestartSec = 20;
         EnvironmentFile = "/var/lib/mastodon/.secrets_env";
         WorkingDirectory = cfg.package;
+        SyslogIdentifier = "mastodon-web";
         # Runtime directory and mode
         RuntimeDirectory = "mastodon-web";
         RuntimeDirectoryMode = "0750";
@@ -732,6 +737,8 @@ in {
       serviceConfig = {
         Type = "oneshot";
         EnvironmentFile = "/var/lib/mastodon/.secrets_env";
+        WorkingDirectory = cfg.package;
+        SyslogIdentifier = "mastodon-media-auto-remove";
       } // cfgService;
       script = let
         olderThanDays = toString cfg.mediaAutoRemove.olderThanDays;

Result:

example mastodon-sidekiq[9745]: 2022-11-23T06:58:50.071Z pid=9745 tid=29ix INFO: queueing Scheduler::SuspendedUserCleanupScheduler (suspended_user_cleanup_scheduler)
example mastodon-sidekiq[9745]: 2022-11-23T06:58:50.072Z pid=9745 tid=29hh INFO: queueing Scheduler::AccountsStatusesCleanupScheduler (accounts_statuses_cleanup_scheduler)
example mastodon-sidekiq[9745]: 2022-11-23T06:58:50.072Z pid=9745 tid=295h class=Scheduler::SuspendedUserCleanupScheduler jid=6497e7d20c9c88bc1c7d377c INFO: start
example mastodon-sidekiq[9745]: 2022-11-23T06:58:50.073Z pid=9745 tid=29hh uniquejobs=client until_executed=uniquejobs:267f7fbd35656df9e831cbd0bf6b5ed0 DEBUG: Executed queue.lua in 1ms
example mastodon-sidekiq[9745]: 2022-11-23T06:58:50.074Z pid=9745 tid=29hh uniquejobs=client until_executed=uniquejobs:267f7fbd35656df9e831cbd0bf6b5ed0 DEBUG: Executed lock.lua in 0ms
example mastodon-sidekiq[9745]: 2022-11-23T06:58:50.075Z pid=9745 tid=29il class=Scheduler::AccountsStatusesCleanupScheduler jid=ab74fff671f652b16c9762ee INFO: start
example mastodon-sidekiq[9745]:   AccountDeletionRequest Load (2.8ms)  SELECT "account_deletion_requests".* FROM "account_deletion_requests" ORDER BY "account_deletion_requests"."id" ASC LIMIT $1  [["LIMIT", 10]]
example mastodon-sidekiq[9745]: 2022-11-23T06:58:50.079Z pid=9745 tid=295h class=Scheduler::SuspendedUserCleanupScheduler jid=6497e7d20c9c88bc1c7d377c elapsed=0.007 INFO: done
example mastodon-sidekiq[9745]:   AccountStatusesCleanupPolicy Load (0.3ms)  SELECT "account_statuses_cleanup_policies".* FROM "account_statuses_cleanup_policies" WHERE "account_statuses_cleanup_policies"."enabled" = $1 ORDER BY "account_statuses_cleanup_policies"."id" ASC LIMIT $2  [["enabled", true], ["LIMIT", 1000]]
example mastodon-sidekiq[9745]: 2022-11-23T06:58:50.081Z pid=9745 tid=29il class=Scheduler::AccountsStatusesCleanupScheduler jid=ab74fff671f652b16c9762ee uniquejobs=server until_executed=uniquejobs:267f7fbd35656df9e831cbd0bf6b5ed0 DEBUG: Executed unlock.lua in 0ms
example mastodon-sidekiq[9745]: 2022-11-23T06:58:50.081Z pid=9745 tid=29il class=Scheduler::AccountsStatusesCleanupScheduler jid=ab74fff671f652b16c9762ee elapsed=0.007 INFO: done

example mastodon-sidekiq-ingress[10474]: 2022-11-23T07:00:11.107Z pid=10474 tid=aoy INFO: Booted Rails 6.1.7 application in production environment
example mastodon-sidekiq-ingress[10474]: 2022-11-23T07:00:11.107Z pid=10474 tid=aoy INFO: Running in ruby 3.0.4p208 (2022-04-12 revision 3fa771dded) [x86_64-linux]
example mastodon-sidekiq-ingress[10474]: 2022-11-23T07:00:11.107Z pid=10474 tid=aoy INFO: See LICENSE and the LGPL-3.0 for licensing details.
example mastodon-sidekiq-ingress[10474]: 2022-11-23T07:00:11.107Z pid=10474 tid=aoy INFO: Upgrade to Sidekiq Pro for more features and support: https://sidekiq.org
example mastodon-sidekiq-ingress[10474]: 2022-11-23T07:00:11.112Z pid=10474 tid=aoy INFO: Loading Schedule
example mastodon-sidekiq-ingress[10474]: 2022-11-23T07:00:11.112Z pid=10474 tid=aoy INFO: Ignoring scheduled_statuses_scheduler, job's queue is not enabled.
example mastodon-sidekiq-ingress[10474]: 2022-11-23T07:00:11.112Z pid=10474 tid=aoy INFO: Ignoring trends_refresh_scheduler, job's queue is not enabled.
example mastodon-sidekiq-ingress[10474]: 2022-11-23T07:00:11.112Z pid=10474 tid=aoy INFO: Ignoring trends_review_notifications_scheduler, job's queue is not enabled.
example mastodon-sidekiq-ingress[10474]: 2022-11-23T07:00:11.112Z pid=10474 tid=aoy INFO: Ignoring indexing_scheduler, job's queue is not enabled.
example mastodon-sidekiq-ingress[10474]: 2022-11-23T07:00:11.112Z pid=10474 tid=aoy INFO: Ignoring vacuum_scheduler, job's queue is not enabled.
example mastodon-sidekiq-ingress[10474]: 2022-11-23T07:00:11.112Z pid=10474 tid=aoy INFO: Ignoring follow_recommendations_scheduler, job's queue is not enabled.
example mastodon-sidekiq-ingress[10474]: 2022-11-23T07:00:11.112Z pid=10474 tid=aoy INFO: Ignoring user_cleanup_scheduler, job's queue is not enabled.
example mastodon-sidekiq-ingress[10474]: 2022-11-23T07:00:11.112Z pid=10474 tid=aoy INFO: Ignoring ip_cleanup_scheduler, job's queue is not enabled.
example mastodon-sidekiq-ingress[10474]: 2022-11-23T07:00:11.112Z pid=10474 tid=aoy INFO: Ignoring pghero_scheduler, job's queue is not enabled.
example mastodon-sidekiq-ingress[10474]: 2022-11-23T07:00:11.112Z pid=10474 tid=aoy INFO: Ignoring instance_refresh_scheduler, job's queue is not enabled.
example mastodon-sidekiq-ingress[10474]: 2022-11-23T07:00:11.112Z pid=10474 tid=aoy INFO: Ignoring accounts_statuses_cleanup_scheduler, job's queue is not enabled.
example mastodon-sidekiq-ingress[10474]: 2022-11-23T07:00:11.112Z pid=10474 tid=aoy INFO: Ignoring suspended_user_cleanup_scheduler, job's queue is not enabled.
example mastodon-sidekiq-ingress[10474]: 2022-11-23T07:00:11.112Z pid=10474 tid=aoy INFO: Schedules Loaded
example mastodon-sidekiq-ingress[10474]: 2022-11-23T07:00:11.113Z pid=10474 tid=aoy DEBUG: Executed update_version.lua in 1ms
example mastodon-sidekiq-ingress[10474]: 2022-11-23T07:00:11.114Z pid=10474 tid=aoy uniquejobs=upgrade_locks INFO: Skipping upgrade because uniquejobs:dead has been set
example mastodon-sidekiq-ingress[10474]: 2022-11-23T07:00:11.114Z pid=10474 tid=aoy uniquejobs=reaper INFO: Starting Reaper
example mastodon-sidekiq-ingress[10474]: 2022-11-23T07:00:11.115Z pid=10474 tid=aoy DEBUG: Client Middleware: SidekiqUniqueJobs::Middleware::Client
example mastodon-sidekiq-ingress[10474]: 2022-11-23T07:00:11.115Z pid=10474 tid=aoy DEBUG: Server Middleware: Mastodon::SidekiqMiddleware, SidekiqUniqueJobs::Middleware::Server
example mastodon-sidekiq-ingress[10474]: 2022-11-23T07:00:11.115Z pid=10474 tid=aoy DEBUG: Sidekiq
example mastodon-sidekiq-ingress[10474]: 2022-11-23T07:00:11.118Z pid=10474 tid=29xm uniquejobs=reaper INFO: Nothing to delete; exiting.
example mastodon-sidekiq-ingress[10474]: 2022-11-23T07:00:11.122Z pid=10474 tid=29xm uniquejobs=reaper INFO: Nothing to delete; exiting.

You have an extra space on this line:

    sidekiqUnits = lib.attrsets.mapAttrs' (name: processCfg: 

@Izorkin
Copy link
Contributor

Izorkin commented Nov 23, 2022

Can we add mastodon-sidekiq.target to combine all mastodon-sidekiq services or mastodon.target to combine all mastodon-* services

@vivlim
Copy link
Contributor Author

vivlim commented Nov 25, 2022

done. I also moved the working directory config to the common service config.

@Izorkin
Copy link
Contributor

Izorkin commented Nov 25, 2022

@vivlim needed remove extra space:

git apply 202408.patch
202408.patch:29: trailing whitespace.
  sidekiqUnits = lib.attrsets.mapAttrs' (name: processCfg:
warning: 1 line adds whitespace errors.

And add small fix:

diff --git a/nixos/modules/services/web-apps/mastodon.nix b/nixos/modules/services/web-apps/mastodon.nix
index 48e64e1df6f..8659cbe2860 100644
--- a/nixos/modules/services/web-apps/mastodon.nix
+++ b/nixos/modules/services/web-apps/mastodon.nix
@@ -636,10 +636,10 @@ in {
         Restart = "always";
         RestartSec = 20;
         EnvironmentFile = "/var/lib/mastodon/.secrets_env";
+        SyslogIdentifier = "mastodon-streaming";
         # Runtime directory and mode
         RuntimeDirectory = "mastodon-streaming";
         RuntimeDirectoryMode = "0750";
-        SyslogIdentifier = "mastodon-streaming";
         # System Call Filtering
         SystemCallFilter = [ ("~" + lib.concatStringsSep " " (systemCallsList ++ [ "@memlock" "@resources" ])) "pipe" "pipe2" ];
       } // cfgService;
@@ -663,10 +663,10 @@ in {
         Restart = "always";
         RestartSec = 20;
         EnvironmentFile = "/var/lib/mastodon/.secrets_env";
+        SyslogIdentifier = "mastodon-web";
         # Runtime directory and mode
         RuntimeDirectory = "mastodon-web";
         RuntimeDirectoryMode = "0750";
-        SyslogIdentifier = "mastodon-web";
         # System Call Filtering
         SystemCallFilter = [ ("~" + lib.concatStringsSep " " systemCallsList) "@chown" "pipe" "pipe2" ];
       } // cfgService;

@vivlim
Copy link
Contributor Author

vivlim commented Nov 25, 2022

I thought I removed the trailing space in 85a32a465. Are you referring to the space between lib.attrsets.mapAttrs' and (name:...?

@Izorkin
Copy link
Contributor

Izorkin commented Nov 25, 2022

Here:

diff --git a/nixos/modules/services/web-apps/mastodon.nix b/nixos/modules/services/web-apps/mastodon.nix
index 1e9e04dcc05582..58fd712ff60b2f 100644
--- a/nixos/modules/services/web-apps/mastodon.nix
+++ b/nixos/modules/services/web-apps/mastodon.nix
@@ -100,6 +100,36 @@ let
     eval -- "\$@"
   '';
 
+  sidekiqUnits = lib.attrsets.mapAttrs' (name: processCfg: 
+    lib.nameValuePair "mastodon-sidekiq-${name}" (let

@vivlim vivlim force-pushed the mastodon-configure-sidekiq-processes branch from 1989b9b to 8f7df65 Compare November 25, 2022 06:56
@vivlim
Copy link
Contributor Author

vivlim commented Nov 25, 2022

git show 58fd712ff60b2f only has the changes from my first commit on this branch, i already removed that extra space because it was causing one of the checks to fail.

i squashed the branch to a single commit and force-pushed.

@Izorkin
Copy link
Contributor

Izorkin commented Nov 25, 2022

@vivlim with this configuration:

        sidekiqProcesses = {
          test = {
            jobClasses = [ "default" "push" "pull" "mailers" "scheduler" ];
            threads = 15;
          };
        };

Result:

systemctl status mastodon-sidekiq-test.service
● mastodon-sidekiq-test.service - Mastodon sidekiq-default-push-pull-mailers-scheduler
     Loaded: loaded (/etc/systemd/system/mastodon-sidekiq-test.service; enabled; preset: enabled)
     Active: active (running) since Fri 2022-11-25 06:22:13 UTC; 48min ago
   Main PID: 72669 (sidekiq)
         IP: 2.7M in, 4.8M out
         IO: 0B read, 1.8M written
      Tasks: 25 (limit: 4699)
     Memory: 229.1M
        CPU: 16.329s
     CGroup: /system.slice/mastodon-sidekiq-test.service
             └─72669 "sidekiq 6.5.7 ajvi1m3h9hj0720ylykgl1csmyp30aak-mastodon-4.0.2 [0 of 15 busy]"

Nov 25 07:10:26 example mastodon-sidekiq-default-push-pull-mailers-scheduler[72669]: 2022-11-25T07:10:26.321Z pid=72669 tid=vs9 INFO: queueing Scheduler::AccountsStatusesCleanupSc>
Nov 25 07:10:26 example mastodon-sidekiq-default-push-pull-mailers-scheduler[72669]: 2022-11-25T07:10:26.322Z pid=72669 tid=x6h class=Scheduler::SuspendedUserCleanupScheduler jid=>
Nov 25 07:10:26 example mastodon-sidekiq-default-push-pull-mailers-scheduler[72669]: 2022-11-25T07:10:26.323Z pid=72669 tid=vs9 uniquejobs=client until_executed=uniquejobs:267f7fb>
Nov 25 07:10:26 example mastodon-sidekiq-default-push-pull-mailers-scheduler[72669]: 2022-11-25T07:10:26.325Z pid=72669 tid=vs9 uniquejobs=client until_executed=uniquejobs:267f7fb>
Nov 25 07:10:26 example mastodon-sidekiq-default-push-pull-mailers-scheduler[72669]:   AccountDeletionRequest Load (0.4ms)  SELECT "account_deletion_requests".* FROM "account_dele>
Nov 25 07:10:26 example mastodon-sidekiq-default-push-pull-mailers-scheduler[72669]: 2022-11-25T07:10:26.326Z pid=72669 tid=wy1 class=Scheduler::AccountsStatusesCleanupScheduler j>
Nov 25 07:10:26 example mastodon-sidekiq-default-push-pull-mailers-scheduler[72669]: 2022-11-25T07:10:26.326Z pid=72669 tid=x6h class=Scheduler::SuspendedUserCleanupScheduler jid=>
Nov 25 07:10:26 example mastodon-sidekiq-default-push-pull-mailers-scheduler[72669]:   AccountStatusesCleanupPolicy Load (0.3ms)  SELECT "account_statuses_cleanup_policies".* FROM>
Nov 25 07:10:26 example mastodon-sidekiq-default-push-pull-mailers-scheduler[72669]: 2022-11-25T07:10:26.334Z pid=72669 tid=wy1 class=Scheduler::AccountsStatusesCleanupScheduler j>
Nov 25 07:10:26 example mastodon-sidekiq-default-push-pull-mailers-scheduler[72669]: 2022-11-25T07:10:26.334Z pid=72669 tid=wy1 class=Scheduler::AccountsStatusesCleanupScheduler j>

Is it possible to replace sidekiq-default-push-pull-mailers-scheduler to sidekiq-test

@vivlim vivlim force-pushed the mastodon-configure-sidekiq-processes branch from 8f7df65 to 145a80f Compare November 25, 2022 07:32
@vivlim
Copy link
Contributor Author

vivlim commented Nov 25, 2022

using the jobClassLabel there was your suggestion, but sure, I changed it to use name and force pushed again.

@Izorkin
Copy link
Contributor

Izorkin commented Nov 25, 2022

using the jobClassLabel there was your suggestion

Sorry, I didn't fully check the PR.

Instead of , it is better to leave -.

diff --git a/nixos/modules/services/web-apps/mastodon.nix b/nixos/modules/services/web-apps/mastodon.nix
index f8998a002af..61d413c2a51 100644
--- a/nixos/modules/services/web-apps/mastodon.nix
+++ b/nixos/modules/services/web-apps/mastodon.nix
@@ -105,7 +105,7 @@ let
   sidekiqUnits = lib.attrsets.mapAttrs' (name: processCfg:
     lib.nameValuePair "mastodon-sidekiq-${name}" (let
       jobClassArgs = lib.concatStringsSep " " (builtins.map (c: "-q ${c}") processCfg.jobClasses);
-      jobClassLabel = lib.concatStringsSep "," ([""] ++ processCfg.jobClasses);
+      jobClassLabel = lib.concatStringsSep "-" ([""] ++ processCfg.jobClasses);
       threads = toString (if processCfg.threads == null then cfg.sidekiqThreads else processCfg.threads);
     in {
       after = [ "network.target" "mastodon-init-dirs.service" ]

@vivlim vivlim force-pushed the mastodon-configure-sidekiq-processes branch from 145a80f to 3b3917f Compare November 25, 2022 08:27
@vivlim
Copy link
Contributor Author

vivlim commented Nov 25, 2022

using the jobClassLabel there was your suggestion

Sorry, I didn't fully check the PR.

Instead of , it is better to leave -.

diff --git a/nixos/modules/services/web-apps/mastodon.nix b/nixos/modules/services/web-apps/mastodon.nix
index f8998a002af..61d413c2a51 100644
--- a/nixos/modules/services/web-apps/mastodon.nix
+++ b/nixos/modules/services/web-apps/mastodon.nix
@@ -105,7 +105,7 @@ let
   sidekiqUnits = lib.attrsets.mapAttrs' (name: processCfg:
     lib.nameValuePair "mastodon-sidekiq-${name}" (let
       jobClassArgs = lib.concatStringsSep " " (builtins.map (c: "-q ${c}") processCfg.jobClasses);
-      jobClassLabel = lib.concatStringsSep "," ([""] ++ processCfg.jobClasses);
+      jobClassLabel = lib.concatStringsSep "-" ([""] ++ processCfg.jobClasses);
       threads = toString (if processCfg.threads == null then cfg.sidekiqThreads else processCfg.threads);
     in {
       after = [ "network.target" "mastodon-init-dirs.service" ]

Changed it back to using spaces, it's used in the description field which already contains a space. I prefer the way Mastodon sidekiq default push pull looks to Mastodon sidekiq-default-push-pull.

@Izorkin
Copy link
Contributor

Izorkin commented Nov 25, 2022

I prefer the way Mastodon sidekiq default push pull looks to Mastodon sidekiq-default-push-pull.

Looked at it now, yes I agree with that. Now it does not affect format in systemd journal.

@vivlim
Copy link
Contributor Author

vivlim commented Dec 1, 2022

@happy-river / @erictapen could one of you please take a look at this when you have a moment?

@Izorkin
Copy link
Contributor

Izorkin commented Dec 1, 2022

Change jobClassLabel = lib.concatStringsSep " " ([""] ++ processCfg.jobClasses); to jobClassLabel = lib.concatStringsSep "-" ([""] ++ processCfg.jobClasses); or jobClassLabel = lib.concatStringsSep "," ([""] ++ processCfg.jobClasses);?

@vivlim
Copy link
Contributor Author

vivlim commented Dec 2, 2022

Why? I want to stop churning on the label without having an explicit reason, we have already gone back and forth enough.

@erictapen erictapen self-requested a review December 5, 2022 17:03
Copy link
Member

@erictapen erictapen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your PR and the extensive explanations you provided with it.

I have some minor nits and questions but this looks like it is more or less ready to go. Also there seem to be some merge conflicts remaining.

@Izorkin The changes regarding SyslogIdentifier and mastodon.target didn't have anything to do with the scope of this PR. Please propose changes like this in separate PRs that just tackle one issue at a time, instead of sneaking them in in reviews. Makes the review process easier. For now I'd say the changes are uncontroversial enough to keep them in.

@ofborg ofborg bot added the 2.status: merge conflict This PR has merge conflicts with the target branch label Dec 5, 2022
This change allows the number of sidekiq processes and which job classes
they handle to be configured.

An instance admin may choose to have separate sidekiq processes handling
jobs related to local users (`default` job class) and jobs related to
federation (`push`, `pull`, `ingress`), so that as the instance grows
and takes on more federation traffic, the local users' experience is not
as impacted.

For more details, see https://docs.joinmastodon.org/admin/scaling/#sidekiq

This pr also includes the following changes suggested in review:

- adds syslog identifiers for mastodon services
- moves working directory config to common cfgService
- adds mastodon.target
@vivlim vivlim force-pushed the mastodon-configure-sidekiq-processes branch from 329b927 to f5470fe Compare February 21, 2023 00:13
@ofborg ofborg bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Feb 21, 2023
@@ -48,6 +48,8 @@ let
# User and group
User = cfg.user;
Group = cfg.group;
# Working directory
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to repeat the actual code in a comment. Similar existing comments should be dropped, too.

@vivlim
Copy link
Contributor Author

vivlim commented Apr 6, 2023

Sorry for the delay on this, the earlier churning on labels and such in this PR really sapped my motivation to push this and it hasn’t come back yet.

@erictapen erictapen merged commit c778f4d into NixOS:master Apr 6, 2023
@erictapen
Copy link
Member

erictapen commented Apr 6, 2023

I just added the assertion I wanted to have, ran the two integration tests and merged, as they were green.

Thanks again for your work and the extensive explanations to it, @vivlim. I'm sorry that the review process diminished your motivation. By giving the discussion a second read, I feel like the request for SyslogIdentifier's was really unnecessary, as we haven't even used these before in the module. Should have been a separate PR.

I hope you haven't lost all interest in contributing to the Mastodon module on NixOS, would be glad to review another PR by you or maybe even see you as a maintainer!

@Janik-Haag Janik-Haag added the 12. first-time contribution This PR is the author's first one; please be gentle! label Jun 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 12. first-time contribution This PR is the author's first one; please be gentle!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants