From 2f9d3293511b7b8cc5a38d75c76bc2288c1fbecc Mon Sep 17 00:00:00 2001 From: David Thompson Date: Thu, 28 Dec 2023 11:20:12 -0500 Subject: takemi: os: Factorize nginx signal code. --- takemi-os.scm | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/takemi-os.scm b/takemi-os.scm index b58417b..a32ae59 100644 --- a/takemi-os.scm +++ b/takemi-os.scm @@ -29,6 +29,12 @@ (shell (file-append (specification->package "shadow") "/sbin/nologin"))))) +(define (nginx-signal name signal) + (program-file + name + #~(let ((pid (call-with-input-file "/var/run/nginx/pid" read))) + (kill pid #$signal)))) + ;; Need to override the default nginx service account configuration so ;; that the nginx user is a member of the git group. (define nginx-service-type* @@ -132,12 +138,7 @@ ;; Send SIGHUP signal to nginx to trigger a ;; configuration reload, thus loading the ;; updated certificates. - (deploy-hook (program-file - "nginx-deploy-hook" - #~(let ((pid (call-with-input-file - "/var/run/nginx/pid" - read))) - (kill pid SIGHUP))))))) + (deploy-hook (nginx-signal "nginx-deploy-hook" SIGHUP))))) (webroot "/var/www/certbot"))) (service nginx-service-type* (nginx-configuration @@ -298,13 +299,7 @@ "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))))) + (post-rotate (nginx-signal "nginx-post-rotate-hook" SIGUSR1))) (log-rotation (frequency 'daily) (files '("/var/log/fcgiwrap.log")) -- cgit v1.2.3