feat(host/faunus-ater): slicify seaweedfs

This commit is contained in:
Malte Tammena 2024-04-03 12:55:16 +02:00
parent 7fca8a6402
commit 8af9f19ab2

View file

@ -1,5 +1,6 @@
{
pkgs,
lib,
config,
...
}: let
@ -20,8 +21,6 @@
in {
enable = true;
description = "SeaweedFS Volume ${builtins.toString number}";
after = ["network.target"];
wantedBy = ["multi-user.target"];
serviceConfig = {
Type = "simple";
ExecStart = "${weed} volume -dir=. -mserver=${master.ip}:${master.port} -ip=${master.ip} -port ${builtins.toString port} -dataCenter=home1 -rack=rack1 -minFreeSpace=50G -max=0 -disk=${disk}";
@ -30,7 +29,9 @@
Group = "seaweed";
Restart = "always";
SyslogIdentifier = "seaweedfs-volume-${builtins.toString number}";
Slice = "system-seaweedfs.slice";
};
wantedBy = ["multi-user.target"];
};
filerConfig = pkgs.writeText "filer.toml" ''
@ -90,13 +91,22 @@ in {
"L+ /data/dirty/seaweedfs/master.toml - - - - ${masterConfig}"
];
systemd.slices."system-seaweedfs" = let
systemdDeps = lib.throwIfNot config.services.tailscale.enable "Tailscale is not enabled, but the seaweed services depend on it. Fix the dependencies or enable tailscale" ["network.target" "tailscaled.service"];
in {
enable = true;
description = "SeaweedFS Systemd Slice";
documentation = ["https://github.com/seaweedfs/seaweedfs/wiki"];
after = systemdDeps;
requires = systemdDeps;
wantedBy = ["multi-user.target"];
};
systemd.services = {
# Master
seaweedfs-master = {
enable = true;
description = "SeaweedFS Server Master";
after = ["network.target"];
wantedBy = ["multi-user.target"];
serviceConfig = {
Type = "simple";
ExecStart = "${weed} master -mdir=. -ip=${master.ip} -port=${master.port} -volumeSizeLimitMB=1024";
@ -105,7 +115,9 @@ in {
Group = "seaweed";
Restart = "always";
SyslogIdentifier = "seaweedfs-master";
Slice = "system-seaweedfs.slice";
};
wantedBy = ["multi-user.target"];
};
# volumes
seaweedfs-volume-dirty = seaweedfsVolume {
@ -142,8 +154,6 @@ in {
seaweedfs-filer = {
enable = true;
description = "SeaweedFS Filer";
after = ["network.target"];
wantedBy = ["multi-user.target"];
serviceConfig = {
Type = "simple";
# TODO: Restrict s3 access and expose filer?
@ -153,18 +163,26 @@ in {
Group = "seaweed";
Restart = "always";
SyslogIdentifier = "seaweedfs-filer";
Slice = "system-seaweedfs.slice";
};
wantedBy = ["multi-user.target"];
};
};
systemd.mounts = [
# This sucks, as weed forks and systemd doesn't like that for mounts.. I'm clueless though
systemd.mounts = let
deps = [
"seaweedfs-master.service"
"seaweedfs-filer.service"
];
in [
{
what = "fuse";
where = "/data/media";
type = "weed";
options = "filer=localhost:8888,filer.path=/archive/media";
after = ["seaweedfs-filer.service"];
requires = ["seaweedfs-filer.service"];
after = deps;
requires = deps;
wantedBy = ["multi-user.target"];
}
];