guix-commits
[Top][All Lists]
Advanced

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

branch master updated: sysadmin: web: Jobs run at most for the duration


From: Ludovic Courtès
Subject: branch master updated: sysadmin: web: Jobs run at most for the duration of their period.
Date: Fri, 03 Dec 2021 06:48:12 -0500

This is an automated email from the git hooks/post-receive script.

civodul pushed a commit to branch master
in repository maintenance.

The following commit(s) were added to refs/heads/master by this push:
     new 5e06b5d  sysadmin: web: Jobs run at most for the duration of their 
period.
5e06b5d is described below

commit 5e06b5d8b533b660d023c8f9f0bc16b3842f612b
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Fri Dec 3 12:45:53 2021 +0100

    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'.
---
 hydra/modules/sysadmin/web.scm | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/hydra/modules/sysadmin/web.scm b/hydra/modules/sysadmin/web.scm
index a3d1ce3..e964818 100644
--- a/hydra/modules/sysadmin/web.scm
+++ b/hydra/modules/sysadmin/web.scm
@@ -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



reply via email to

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