hercules-ci / arion

Run docker-compose with help from Nix/NixOS
Apache License 2.0
622 stars 48 forks source link

Allow setting log namespaces for systemd services generated by Arion on NixOS #244

Open nikp123 opened 3 months ago

nikp123 commented 3 months ago

The idea is pretty simple, in the generated arion-${containerName}.service file, set an additional option in the [Service] section called LogNamespace=${containerName}.

The rationale: This is used in case we want to limit the size of the journal but don't want it to be globally smaller for services that output logs rarely. An example would be caddy which outputs logs for EVERY single access attempt, meanwhile something like cloudflare-dyndns would do it rarely. The result is that I lose useful dyndns logs because caddy eats up most of that journal log size.

IDEALLY, we would be able to set log sizes per unit, but that's currently a TODO in the main systemd repository. See: https://github.com/systemd/systemd/issues/9519

By setting a log namespace we're able to isolate logs more clearly and set log settings per namespace, thus effectively achieving the same thing.

Yes, this is indeed a workaround on a SystemD issue, but since there's no activity on their side, I think it's valid to ask for this feature here. Apologies in advance if this seems inappropriate.