me
/
guix
Archived
1
0
Fork 0

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.
master
Ludovic Courtès 2020-08-24 22:59:43 +02:00
parent 384377632c
commit fe42e5f39c
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
1 changed files with 23 additions and 27 deletions

View File

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