Skip to content

Commit

Permalink
[nix] Allow directing services' stdout to logfiles
Browse files Browse the repository at this point in the history
  • Loading branch information
otargowski committed Nov 25, 2023
1 parent 2a9e14d commit ab26268
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 8 deletions.
32 changes: 25 additions & 7 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions nix/module/worker.nix
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@
description = "The amount of memory (in megabytes) this worker will use";
type = lib.types.ints.unsigned;
};

separateStdoutFromJournal = lib.mkOption {
default = false;
description = ''
Redirect sioworker's stdout to a file in /var/log/sio2.
You have to ensure that directory exists and rotate the logs yourself,
unless you use talentsio, which does the former.
'';
type = lib.types.bool;
};
};

config =
Expand Down Expand Up @@ -100,6 +110,9 @@
CacheDirectory = "sioworker";
AmbientCapabilities = [ "CAP_PERFMON" ];
PIDFile = "/run/sioworker/sioworker.pid";
# S*stemd is retarded and tries to open the stdout file first
#LogsDirectory = lib.mkIf cfg.separateStdoutFromJournal "sio2";
StandardOutput = lib.mkIf cfg.separateStdoutFromJournal "append:/var/log/sio2/sioworker.log";

User = "sioworker";
Group = "sioworker";
Expand Down
14 changes: 13 additions & 1 deletion nix/module/workersd.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
type = lib.types.ints.unsigned;
};


worker = lib.mkOption {
default = { };
description = "The worker listen address and port";
Expand Down Expand Up @@ -48,6 +47,16 @@
};
};
};

separateStdoutFromJournal = lib.mkOption {
default = false;
description = ''
Redirect sioworkersd's stdout to a file in /var/log/sio2.
You have to ensure that directory exists and rotate the logs yourself,
unless you use talentsio, which does the former.
'';
type = lib.types.bool;
};
};

config =
Expand Down Expand Up @@ -91,6 +100,9 @@
RuntimeDirectory = "sioworkersd";
StateDirectory = "sioworkersd";
PIDFile = "/run/sioworkersd/sioworkersd.pid";
# S*stemd is retarded and tries to open the stdout file first
#LogsDirectory = lib.mkIf cfg.separateStdoutFromJournal "sio2";
StandardOutput = lib.mkIf cfg.separateStdoutFromJournal "append:/var/log/sio2/sioworkersd.log";

User = "sioworkersd";
Group = "sioworkersd";
Expand Down

0 comments on commit ab26268

Please sign in to comment.