rails: Automatically rotate log files

This commit is contained in:
Peter Jones 2019-01-04 17:08:10 -07:00
parent c5dc7d83be
commit 72d3974626
No known key found for this signature in database
GPG key ID: 9DAFAA8D01941E49

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);
};
};
}