Merge pull request #175558 from klemensn/atop-convert-logs-fix-startup
nixos/atop: Convert log format to fix service start
This commit is contained in:
commit
39e6b1a240
1 changed files with 18 additions and 0 deletions
|
@ -136,6 +136,24 @@ in
|
|||
packages = [ atop (lib.mkIf cfg.netatop.enable cfg.netatop.package) ];
|
||||
services =
|
||||
mkService cfg.atopService.enable "atop" [ atop ]
|
||||
// lib.mkIf cfg.atopService.enable {
|
||||
# always convert logs to newer version first
|
||||
# XXX might trigger TimeoutStart but restarting atop.service will
|
||||
# convert remainings logs and start eventually
|
||||
atop.serviceConfig.ExecStartPre = pkgs.writeShellScript "atop-update-log-format" ''
|
||||
set -e -u
|
||||
for logfile in "$LOGPATH"/atop_*
|
||||
do
|
||||
${atop}/bin/atopconvert "$logfile" "$logfile".new
|
||||
# only replace old file if version was upgraded to avoid
|
||||
# false positives for atop-rotate.service
|
||||
if ! ${pkgs.diffutils}/bin/cmp -s "$logfile" "$logfile".new
|
||||
then
|
||||
${pkgs.coreutils}/bin/mv -v -f "$logfile".new "$logfile"
|
||||
fi
|
||||
done
|
||||
'';
|
||||
}
|
||||
// mkService cfg.atopacctService.enable "atopacct" [ atop ]
|
||||
// mkService cfg.netatop.enable "netatop" [ cfg.netatop.package ]
|
||||
// mkService cfg.atopgpu.enable "atopgpu" [ atop ];
|
||||
|
|
Loading…
Reference in a new issue