mirror of
git://git.savannah.gnu.org/guix/maintenance.git
synced 2023-12-14 03:33:04 +01:00
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
|
(define* (build-program url root
|
||||||
#:key
|
#:key
|
||||||
|
(max-duration 3600)
|
||||||
(file "guix.scm")
|
(file "guix.scm")
|
||||||
(ref '(branch . "master"))
|
(ref '(branch . "master"))
|
||||||
(name "build-program")
|
(name "build-program")
|
||||||
|
@ -71,7 +72,8 @@ that's built with Haunt or similar."
|
||||||
(with-extensions guix-extensions
|
(with-extensions guix-extensions
|
||||||
#~(begin
|
#~(begin
|
||||||
(use-modules (guix) (guix git) (guix ui)
|
(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)
|
(define (root-installed drv root)
|
||||||
(mbegin %store-monad
|
(mbegin %store-monad
|
||||||
|
@ -107,6 +109,24 @@ that's built with Haunt or similar."
|
||||||
variables)
|
variables)
|
||||||
(primitive-load (string-append checkout "/" #$file))))
|
(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
|
(with-store store
|
||||||
(run-with-store store
|
(run-with-store store
|
||||||
(mlet %store-monad ((drv (lower-object obj)))
|
(mlet %store-monad ((drv (lower-object obj)))
|
||||||
|
@ -144,6 +164,7 @@ that's built with Haunt or similar."
|
||||||
(define update
|
(define update
|
||||||
(build-program (static-web-site-configuration-git-url config)
|
(build-program (static-web-site-configuration-git-url config)
|
||||||
(static-web-site-configuration-directory config)
|
(static-web-site-configuration-directory config)
|
||||||
|
#:max-duration (static-web-site-configuration-period config)
|
||||||
#:file (static-web-site-configuration-build-file config)
|
#:file (static-web-site-configuration-build-file config)
|
||||||
#:ref (static-web-site-configuration-git-ref config)
|
#:ref (static-web-site-configuration-git-ref config)
|
||||||
#:environment-variables
|
#:environment-variables
|
||||||
|
|
Loading…
Reference in a new issue