Browse Source

rails: Automatically rotate log files

pjones/monitoring
Peter J. Jones 10 months ago
parent
commit
72d3974626
Signed by: Peter Jones <pjones@devalot.com> GPG Key ID: 9DAFAA8D01941E49
1 changed files with 21 additions and 0 deletions
  1. 21
    0
      modules/services/web/rails/default.nix

+ 21
- 0
modules/services/web/rails/default.nix View File

@@ -76,6 +76,21 @@ let
};
};

##############################################################################
# Log rotation:
appLogRotation = app:
''
${app.home}/log/*.log {
size 64M
rotate 16
missingok
compress
delaycompress
notifempty
copytruncate
}
'';

##############################################################################
# Generate a systemd service for a Ruby on Rails application:
appService = app: service: {
@@ -202,5 +217,11 @@ in
# Each application gets one or more systemd services to keep it
# running.
systemd.services = collectApps appServices;

# Rotate all of the log files:
services.logrotate = {
enable = true;
config = concatMapStringsSep "\n" appLogRotation (attrValues cfg.apps);
};
};
}

Loading…
Cancel
Save