mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-11-07 07:26:13 -05:00
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.
This commit is contained in:
parent
384377632c
commit
fe42e5f39c
1 changed files with 23 additions and 27 deletions
|
@ -255,13 +255,6 @@ (define (alarm-handler . _)
|
|||
(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 @@ (define-syntax-rule (with-logging exp ...)
|
|||
(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)
|
||||
;; Redirect stdout/stderr to LOG to save the output of 'guix' below.
|
||||
(redirect-port log (current-output-port))
|
||||
(redirect-port log (current-error-port))
|
||||
|
||||
;; '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 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)
|
||||
|
||||
(format #t "~a restarting services...~%" (timestamp))
|
||||
(for-each restart-service '#$services)
|
||||
;; '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")))
|
||||
|
||||
;; XXX: If 'mcron' has been restarted, perhaps this isn't
|
||||
;; reached.
|
||||
(format #t "~a upgrade complete~%" (timestamp)))))))
|
||||
(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))
|
||||
|
|
Loading…
Reference in a new issue