sysadmin: web: Jobs run at most for the duration of their period.
* hydra/modules/sysadmin/web.scm (build-program): Add #:max-duration parameter. [build]: Add calls to 'sigaction' and 'alarm'. Add some logging. (static-web-site-mcron-jobs): Pass #:max-duration to 'build-program'.
This commit is contained in:
parent
dd41159f75
commit
5e06b5d8b5
|
@ -55,6 +55,7 @@
|
|||
|
||||
(define* (build-program url root
|
||||
#:key
|
||||
(max-duration 3600)
|
||||
(file "guix.scm")
|
||||
(ref '(branch . "master"))
|
||||
(name "build-program")
|
||||
|
@ -71,7 +72,8 @@ that's built with Haunt or similar."
|
|||
(with-extensions guix-extensions
|
||||
#~(begin
|
||||
(use-modules (guix) (guix git) (guix ui)
|
||||
(srfi srfi-11) (ice-9 match))
|
||||
(srfi srfi-11) (srfi srfi-19)
|
||||
(ice-9 match))
|
||||
|
||||
(define (root-installed drv root)
|
||||
(mbegin %store-monad
|
||||
|
@ -107,6 +109,24 @@ that's built with Haunt or similar."
|
|||
variables)
|
||||
(primitive-load (string-append checkout "/" #$file))))
|
||||
|
||||
(define (timestamp)
|
||||
(date->string (time-utc->date (current-time time-utc))
|
||||
"[~4]"))
|
||||
|
||||
(define (alarm-handler . _)
|
||||
(format #t "~a time is up, aborting web site update~%"
|
||||
(timestamp))
|
||||
(exit 1))
|
||||
|
||||
;; Since this program typically runs periodically, abort after
|
||||
;; MAX-DURATION to avoid spending countless instances of it when,
|
||||
;; for example, the GC lock is held.
|
||||
(sigaction SIGALRM alarm-handler)
|
||||
(alarm #$max-duration)
|
||||
|
||||
(format #t "~a building web site from '~a'...~%"
|
||||
(timestamp) #$url)
|
||||
|
||||
(with-store store
|
||||
(run-with-store store
|
||||
(mlet %store-monad ((drv (lower-object obj)))
|
||||
|
@ -144,6 +164,7 @@ that's built with Haunt or similar."
|
|||
(define update
|
||||
(build-program (static-web-site-configuration-git-url config)
|
||||
(static-web-site-configuration-directory config)
|
||||
#:max-duration (static-web-site-configuration-period config)
|
||||
#:file (static-web-site-configuration-build-file config)
|
||||
#:ref (static-web-site-configuration-git-ref config)
|
||||
#:environment-variables
|
||||
|
|
Loading…
Reference in New Issue