Subject: [PATCH 2/4] services: dovecot: Add 'reopen action.

From: Bruno Victal <[email-masked]>
Date: Sat, 4 Nov 2023 19:05:59 +0000

* gnu/services/mail.scm (dovecot-shepherd-service): Re-indent.
Add 'reopen action.

Change-Id: I333032ec6f8a451c22490e27910793410c63a6d6
---
 gnu/services/mail.scm | 31 +++++++++++++++++++++++--------
 1 file changed, 23 insertions(+), 8 deletions(-)

diff --git a/gnu/services/mail.scm b/gnu/services/mail.scm
index b865a67630..0f287ab93e 100644
--- a/gnu/services/mail.scm
+++ b/gnu/services/mail.scm
@@ -5,6 +5,7 @@
 ;;; Copyright © 2017, 2020 Tobias Geerinckx-Rice <[email-masked]>
 ;;; Copyright © 2019 Kristofer Buffington <[email-masked]>
 ;;; Copyright © 2020 Jonathan Brielmaier <[email-masked]>
+;;; Copyright © 2023 Bruno Victal <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -1575,14 +1576,28 @@ (define (dovecot-shepherd-service config)
   (let ((dovecot (if (opaque-dovecot-configuration? config)
                      (opaque-dovecot-configuration-dovecot config)
                      (dovecot-configuration-dovecot config))))
-    (list (shepherd-service
-           (documentation "Run the Dovecot POP3/IMAP mail server.")
-           (provision '(dovecot))
-           (requirement '(pam networking))
-           (start #~(make-forkexec-constructor
-                     (list #$(file-append dovecot "/sbin/dovecot")
-                           "-F")))
-           (stop #~(make-kill-destructor))))))
+    (list
+     (shepherd-service
+      (documentation "Run the Dovecot POP3/IMAP mail server.")
+      (provision '(dovecot))
+      (requirement '(pam networking))
+      (start #~(make-forkexec-constructor
+                (list #$(file-append dovecot "/sbin/dovecot")
+                      "-F")))
+      (stop #~(make-kill-destructor))
+      (actions
+       (list (shepherd-action
+              (name 'reopen)
+              (documentation "Re-open log files.")
+              (procedure
+               #~(lambda (pid)
+                   (if pid
+                       (begin
+                         (kill pid SIGUSR1)
+                         (format #t
+                                 "Issued SIGUSR1 to Service Dovecot (PID ~a)."
+                                 pid))
+                       (format #t "Service Dovecot is not running.")))))))))))
 
 (define %dovecot-pam-services
   (list (unix-pam-service "dovecot")))
-- 
2.41.0