From e2bcb0048fcd07d7135607eeb60236bae821c07f Mon Sep 17 00:00:00 2001 From: David Thompson Date: Thu, 16 Nov 2023 21:20:27 -0500 Subject: takemi: os: Attempt to rotate nginx and fcgiwrap logs. --- takemi-os.scm | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/takemi-os.scm b/takemi-os.scm index f6c2aec..a35793d 100644 --- a/takemi-os.scm +++ b/takemi-os.scm @@ -1,5 +1,6 @@ (use-modules (gnu) (gnu packages version-control) + (gnu services admin) (gnu services certbot) (gnu services cgit) (gnu services ci) @@ -279,6 +280,33 @@ ;; repos. (group "git") (socket (string-append "tcp:" fcgiwrap-socket)))) + ;; Log rotation. + (simple-service 'rotate-logs + rottlog-service-type + (list (log-rotation + (frequency 'daily) + (files '("/var/log/nginx/access.log" + "/var/log/nginx/error.log")) + (options `( ;; Keep a week of logs. + "rotate 6" + ;; Run post-rotate once per + ;; rotation rather than once + ;; for each file. + "sharedscripts" + ,@%default-log-rotation-options)) + ;; Tell nginx to reopen its log files after rotation. + (post-rotate + (program-file + "nginx-post-rotate-hook" + #~(let ((pid (call-with-input-file + "/var/run/nginx/pid" + read))) + (kill pid SIGUSR1))))) + (log-rotation + (frequency 'daily) + (files '("/var/log/fcgiwrap.log")) + (options `("rotate 6" + ,@%default-log-rotation-options))))) (modify-services %base-services (guix-service-type config => (guix-configuration -- cgit v1.2.3