1
0
Fork 0

afws: enable file logging with afws group permissions

This commit is contained in:
Florian Agbuya 2024-11-22 15:34:23 +08:00
parent 98c1ecd325
commit d1236d548d
1 changed files with 19 additions and 1 deletions

View File

@ -10,16 +10,34 @@ in
default = false; default = false;
description = "Enable AFWS server"; description = "Enable AFWS server";
}; };
logFile = mkOption {
type = types.str;
default = "/var/lib/afws/logs/afws.log";
description = "Path to the log file";
};
logBackupCount = mkOption {
type = types.int;
default = 30;
description = "Number of daily log files to keep";
};
}; };
config = mkIf config.services.afws.enable { config = mkIf config.services.afws.enable {
systemd.services.afws = { systemd.services.afws = {
description = "AFWS server"; description = "AFWS server";
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
preStart = ''
mkdir -p "$(dirname ${config.services.afws.logFile})"
chown afws:afws "$(dirname ${config.services.afws.logFile})"
'';
serviceConfig = { serviceConfig = {
User = "afws"; User = "afws";
Group = "afws"; Group = "afws";
ExecStart = "${afws}/bin/afws_server"; ExecStart = ''
${afws}/bin/afws_server \
--log-file ${config.services.afws.logFile} \
--log-backup-count ${toString config.services.afws.logBackupCount}
'';
ExecReload = "${pkgs.coreutils}/bin/kill -USR1 $MAINPID"; ExecReload = "${pkgs.coreutils}/bin/kill -USR1 $MAINPID";
}; };
path = [ pkgs.nix pkgs.git ]; path = [ pkgs.nix pkgs.git ];