diff mbox series

[bug#66935,v2,2/4] services: dovecot: Add 'reopen action.

Message ID 9d21fd72e0b3ca36325fa79872bcbd07bd330f0a.1699369492.git.mirai@makinata.eu
State New
Headers show
Series None | expand

Commit Message

Bruno Victal Nov. 7, 2023, 3:04 p.m. UTC
* 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 mbox series

Patch

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 <me@tobias.gr>
 ;;; Copyright © 2019 Kristofer Buffington <kristoferbuffington@gmail.com>
 ;;; Copyright © 2020 Jonathan Brielmaier <jonathan.brielmaier@web.de>
+;;; Copyright © 2023 Bruno Victal <mirai@makinata.eu>
 ;;;
 ;;; 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")))