From 9133b7d11aa4dbc4f6b133416491edf31aabdf60 Mon Sep 17 00:00:00 2001 From: Luke Granger-Brown Date: Sun, 20 Oct 2024 18:19:22 +0100 Subject: [PATCH] ops/nixos/seaweedfs: add sync --- ops/nixos/lib/seaweedfs.nix | 43 +++++++++++++++++++++++++++++++++++- ops/nixos/totoro/default.nix | 4 ++++ 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/ops/nixos/lib/seaweedfs.nix b/ops/nixos/lib/seaweedfs.nix index 58c5c33007..bfbc47ab06 100644 --- a/ops/nixos/lib/seaweedfs.nix +++ b/ops/nixos/lib/seaweedfs.nix @@ -138,6 +138,30 @@ in { default = {}; }; }; + + sync = lib.mkOption { + type = lib.types.attrsOf (lib.types.submodule { + options = { + package = lib.mkOption { + type = lib.types.package; + default = cfg.package; + }; + + earlyOptions = lib.mkOption { + type = lib.types.submodule { + freeformType = commandLineType; + }; + default = {}; + }; + options = lib.mkOption { + type = lib.types.submodule { + freeformType = commandLineType; + }; + default = {}; + }; + }; + }); + }; }; config = lib.mkMerge [{ @@ -226,5 +250,22 @@ in { Restart = "always"; }; }; - })]; + }) { + systemd.services = lib.mapAttrs' (k: v: lib.nameValuePair "seaweedfs-sync-${k}" { + wantedBy = [ "seaweedfs.target" ]; + unitConfig = { + StartLimitIntervalSec = "0"; + }; + serviceConfig = { + ExecStart = "${v.package}/bin/weed ${makeCommandLine v.earlyOptions} filer.sync ${makeCommandLine v.options}"; + User = "seaweedfs-sync"; + DynamicUser = true; + Restart = "always"; + + RestartSec = "100ms"; + RestartSteps = 10; + RestartMaxDelaySec = "1min"; + }; + }) cfg.sync; + }]; } diff --git a/ops/nixos/totoro/default.nix b/ops/nixos/totoro/default.nix index c41845edfd..36a4203a73 100644 --- a/ops/nixos/totoro/default.nix +++ b/ops/nixos/totoro/default.nix @@ -627,6 +627,10 @@ in { master = "[${config.my.ip.tailscale6}]:21000"; }; }; + sync.rexxar.options = { + a = "rexxar.int.as205479.net:21010"; + b = "totoro.int.as205479.net:21010"; + }; }; system.stateVersion = "22.11";