[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
02/03: services: web: 'static-web-site-configuration' can specify an upd
From: |
Ludovic Courtès |
Subject: |
02/03: services: web: 'static-web-site-configuration' can specify an update period. |
Date: |
Thu, 28 Oct 2021 11:22:39 -0400 (EDT) |
civodul pushed a commit to branch master
in repository maintenance.
commit bdb914a1242cb0c00957050c96d1e279d2eb5dec
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Thu Oct 28 17:13:20 2021 +0200
services: web: 'static-web-site-configuration' can specify an update period.
* hydra/modules/sysadmin/web.scm (<static-web-site-configuration>)[period]:
New field.
(static-web-site-mcron-jobs): Honor it.
---
hydra/modules/sysadmin/web.scm | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/hydra/modules/sysadmin/web.scm b/hydra/modules/sysadmin/web.scm
index abac188..a3d1ce3 100644
--- a/hydra/modules/sysadmin/web.scm
+++ b/hydra/modules/sysadmin/web.scm
@@ -131,6 +131,8 @@ that's built with Haunt or similar."
(default '(branch . "master")))
(build-file static-web-site-configuration-build-file
(default "guix.scm"))
+ (period static-web-site-configuration-period
+ (default 3600)) ;seconds
(environment-variables static-web-site-configuration-environment-variable
(default '()))
(cache-directory static-web-site-configuration-cache-directory
@@ -153,9 +155,14 @@ that's built with Haunt or similar."
(basename
(static-web-site-configuration-directory
config)))))
- ;; Spread web site updates over the hour to avoid I/O load peaks.
- (let ((minutes (hash (static-web-site-configuration-git-url config) 60)))
- (list #~(job '(next-minute '(#$minutes)) #$update
+ ;; Add an offset to spread web site updates over the period to avoid I/O
+ ;; load peaks when there are several such jobs.
+ (let* ((period (static-web-site-configuration-period config))
+ (offset (hash config period)))
+ (list #~(job (lambda (now)
+ (let ((elapsed (modulo now #$period)))
+ (+ now (- #$period elapsed) #$offset)))
+ #$update
#:user "static-web-site"))))
(define (static-web-site-activation config)