guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

03/03: services: unattended-upgrade: Log output of the 'guix' commands.


From: guix-commits
Subject: 03/03: services: unattended-upgrade: Log output of the 'guix' commands.
Date: Mon, 24 Aug 2020 17:25:16 -0400 (EDT)

civodul pushed a commit to branch master
in repository guix.

commit fe42e5f39c9b36f02beec246b376a50e41114b84
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Mon Aug 24 22:59:43 2020 +0200

    services: unattended-upgrade: Log output of the 'guix' commands.
    
    Fixes <https://bugs.gnu.org/43011>.
    Reported by Jesse Gibbons <jgibbons2357@gmail.com>.
    
    Until now the stdout/stderr file descriptors were not redirected.
    
    * gnu/services/admin.scm (unattended-upgrade-mcron-jobs)[code]: Remove
    'with-logging' and use 'redirect-port' instead.
---
 gnu/services/admin.scm | 56 +++++++++++++++++++++++---------------------------
 1 file changed, 26 insertions(+), 30 deletions(-)

diff --git a/gnu/services/admin.scm b/gnu/services/admin.scm
index 61bc17b..b34b990 100644
--- a/gnu/services/admin.scm
+++ b/gnu/services/admin.scm
@@ -255,13 +255,6 @@ Old log files are removed or compressed according to the 
configuration.")
                     (timestamp))
             (exit 1))
 
-          (define-syntax-rule (with-logging exp ...)
-            (with-output-to-port log
-              (lambda ()
-                (with-error-to-port log
-                  (lambda ()
-                    exp ...)))))
-
           ;; 'guix time-machine' needs X.509 certificates to authenticate the
           ;; Git host.
           (setenv "SSL_CERT_DIR"
@@ -271,29 +264,32 @@ Old log files are removed or compressed according to the 
configuration.")
           (sigaction SIGALRM alarm-handler)
           (alarm #$(unattended-upgrade-maximum-duration config))
 
-          (with-logging
-           (format #t "~a starting upgrade...~%" (timestamp))
-           (guard (c ((invoke-error? c)
-                      (report-invoke-error c)))
-             (invoke #$(file-append guix "/bin/guix")
-                     "time-machine" "-C" #$channels
-                     "--" "system" "reconfigure" #$config-file)
-
-             ;; 'guix system delete-generations' fails when there's no
-             ;; matching generation.  Thus, catch 'invoke-error?'.
-             (guard (c ((invoke-error? c)
-                        (report-invoke-error c)))
-               (invoke #$(file-append guix "/bin/guix")
-                       "system" "delete-generations"
-                       #$(string-append (number->string expiration)
-                                        "s")))
-
-             (format #t "~a restarting services...~%" (timestamp))
-             (for-each restart-service '#$services)
-
-             ;; XXX: If 'mcron' has been restarted, perhaps this isn't
-             ;; reached.
-             (format #t "~a upgrade complete~%" (timestamp)))))))
+          ;; Redirect stdout/stderr to LOG to save the output of 'guix' below.
+          (redirect-port log (current-output-port))
+          (redirect-port log (current-error-port))
+
+          (format #t "~a starting upgrade...~%" (timestamp))
+          (guard (c ((invoke-error? c)
+                     (report-invoke-error c)))
+            (invoke #$(file-append guix "/bin/guix")
+                    "time-machine" "-C" #$channels
+                    "--" "system" "reconfigure" #$config-file)
+
+            ;; 'guix system delete-generations' fails when there's no
+            ;; matching generation.  Thus, catch 'invoke-error?'.
+            (guard (c ((invoke-error? c)
+                       (report-invoke-error c)))
+              (invoke #$(file-append guix "/bin/guix")
+                      "system" "delete-generations"
+                      #$(string-append (number->string expiration)
+                                       "s")))
+
+            (format #t "~a restarting services...~%" (timestamp))
+            (for-each restart-service '#$services)
+
+            ;; XXX: If 'mcron' has been restarted, perhaps this isn't
+            ;; reached.
+            (format #t "~a upgrade complete~%" (timestamp))))))
 
   (define upgrade
     (program-file "unattended-upgrade" code))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]