[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
04/06: hydra: web: 'static-web-site-service-type' handles lists of sites
From: |
Ludovic Courtès |
Subject: |
04/06: hydra: web: 'static-web-site-service-type' handles lists of sites. |
Date: |
Wed, 22 Dec 2021 06:50:13 -0500 (EST) |
civodul pushed a commit to branch master
in repository maintenance.
commit 7b1b28271c7ed630cac221105090a425faa707f7
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Wed Dec 22 12:10:26 2021 +0100
hydra: web: 'static-web-site-service-type' handles lists of sites.
* hydra/modules/sysadmin/web.scm (static-web-site-mcron-jobs): Expect a
list of <static-web-site-configuration> records.
(static-web-site-activation): Likewise.
(static-web-site-accounts): Define using 'const'.
* hydra/website.scm (website-services): Adjust accordingly, using one
'static-web-site-service-type' instance for all of guix.gnu.org.
* hydra/bayfront.scm <services>: Adjust hpc.guix.info instance
accordingly.
---
hydra/bayfront.scm | 2 +-
hydra/modules/sysadmin/web.scm | 60 +++++++++++++++-------------
hydra/website.scm | 91 ++++++++++++++++++++----------------------
3 files changed, 77 insertions(+), 76 deletions(-)
diff --git a/hydra/bayfront.scm b/hydra/bayfront.scm
index 264928e..98ac363 100644
--- a/hydra/bayfront.scm
+++ b/hydra/bayfront.scm
@@ -916,7 +916,7 @@ access_log /var/log/nginx/bordeaux.access.log;"))
;; Runnning hpc.guix.info.
(service static-web-site-service-type
- guix-hpc-web-site)
+ (list guix-hpc-web-site))
;; hpcguix-web as it can be seen at
;; <https://hpc.guix.info/browse>.
diff --git a/hydra/modules/sysadmin/web.scm b/hydra/modules/sysadmin/web.scm
index e964818..c5f994d 100644
--- a/hydra/modules/sysadmin/web.scm
+++ b/hydra/modules/sysadmin/web.scm
@@ -160,8 +160,8 @@ that's built with Haunt or similar."
(directory static-web-site-configuration-directory
(default "/srv/www")))
-(define (static-web-site-mcron-jobs config)
- (define update
+(define (static-web-site-mcron-jobs sites)
+ (define (update config)
(build-program (static-web-site-configuration-git-url config)
(static-web-site-configuration-directory config)
#:max-duration (static-web-site-configuration-period config)
@@ -176,36 +176,40 @@ that's built with Haunt or similar."
(basename
(static-web-site-configuration-directory
config)))))
- ;; 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)
+ (map (lambda (config)
+ ;; 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)))
+ #~(job (lambda (now)
+ (let ((elapsed (modulo now #$period)))
+ (+ now (- #$period elapsed) #$offset)))
+ #$(update config)
+ #:user "static-web-site")))
+ sites))
+
+(define (static-web-site-activation sites)
(with-imported-modules '((guix build utils))
#~(begin
(use-modules (guix build utils))
- (let ((directory (dirname
- #$(static-web-site-configuration-directory config))))
- (mkdir-p directory)
- (chown directory
- (passwd:uid (getpw "static-web-site"))
- (group:gid (getgr "static-web-site")))))))
-
-(define (static-web-site-accounts config)
- (list (user-account
- (name "static-web-site")
- (group "static-web-site")
- (system? #t))
- (user-group
- (name "static-web-site")
- (system? #t))))
+ (for-each (lambda (directory)
+ (let ((directory (dirname directory)))
+ (mkdir-p directory)
+ (chown directory
+ (passwd:uid (getpw "static-web-site"))
+ (group:gid (getgr "static-web-site")))))
+ '#$(map static-web-site-configuration-directory
+ sites)))))
+
+(define static-web-site-accounts
+ (const (list (user-account
+ (name "static-web-site")
+ (group "static-web-site")
+ (system? #t))
+ (user-group
+ (name "static-web-site")
+ (system? #t)))))
(define static-web-site-service-type
(service-type (name 'static-web-site)
diff --git a/hydra/website.scm b/hydra/website.scm
index 5a42a86..9979384 100644
--- a/hydra/website.scm
+++ b/hydra/website.scm
@@ -3,65 +3,62 @@
(list
;; Runnning guix.gnu.org.
(service static-web-site-service-type
- (static-web-site-configuration
- (git-url
- "https://git.savannah.gnu.org/git/guix/guix-artwork.git")
- (directory "/srv/guix.gnu.org")
- (build-file "website/.guix.scm")))
+ (list (static-web-site-configuration
+ (git-url
+ "https://git.savannah.gnu.org/git/guix/guix-artwork.git")
+ (directory "/srv/guix.gnu.org")
+ (build-file "website/.guix.scm"))
- ;; Manual for the latest stable release.
- (service static-web-site-service-type
- (static-web-site-configuration
- (git-url "https://git.savannah.gnu.org/git/guix.git")
- (git-ref '(branch . "version-1.3.0"))
- (period (* 24 3600)) ;check once per day
- (directory "/srv/guix-manual")
- (build-file "doc/build.scm")
- (environment-variables
- '(("GUIX_MANUAL_VERSION" . "1.3.0")
- ("GUIX_WEB_SITE_URL" . "/")))))
+ ;; Manual for the latest stable release.
+ (static-web-site-configuration
+ (git-url "https://git.savannah.gnu.org/git/guix.git")
+ (git-ref '(branch . "version-1.3.0"))
+ (period (* 24 3600)) ;check once per day
+ (directory "/srv/guix-manual")
+ (build-file "doc/build.scm")
+ (environment-variables
+ '(("GUIX_MANUAL_VERSION" . "1.3.0")
+ ("GUIX_WEB_SITE_URL" . "/"))))
- ;; Manual for 'master'.
- (service static-web-site-service-type
- (static-web-site-configuration
- (git-url "https://git.savannah.gnu.org/git/guix.git")
- (directory "/srv/guix-manual-devel")
+ ;; Manual for 'master'.
+ (static-web-site-configuration
+ (git-url "https://git.savannah.gnu.org/git/guix.git")
+ (directory "/srv/guix-manual-devel")
- ;; XXX: Use a different cache directory to work around
- ;; the fact that (guix git) would use a same-named
- ;; checkout directory for 'master' and for the branch
- ;; above. Since both mcron jobs run at the same time,
- ;; they would end up using one branch or the other, in
- ;; a non-deterministic way.
- (cache-directory "guix-master-manual")
+ ;; XXX: Use a different cache directory to work around
+ ;; the fact that (guix git) would use a same-named
+ ;; checkout directory for 'master' and for the branch
+ ;; above. Since both mcron jobs run at the same time,
+ ;; they would end up using one branch or the other, in
+ ;; a non-deterministic way.
+ (cache-directory "guix-master-manual")
- (build-file "doc/build.scm")
- (environment-variables
- '(("GUIX_WEB_SITE_URL" . "/")))))
+ (build-file "doc/build.scm")
+ (environment-variables
+ '(("GUIX_WEB_SITE_URL" . "/"))))
- ;; Cookbook for 'master'.
- (service static-web-site-service-type
- (static-web-site-configuration
- (git-url "https://git.savannah.gnu.org/git/guix.git")
- (directory "/srv/guix-cookbook")
+ ;; Cookbook for 'master'.
+ (static-web-site-configuration
+ (git-url "https://git.savannah.gnu.org/git/guix.git")
+ (directory "/srv/guix-cookbook")
- ;; XXX: Use a different cache directory (see above).
- (cache-directory "guix-cookbook-master")
+ ;; XXX: Use a different cache directory (see above).
+ (cache-directory "guix-cookbook-master")
- (build-file "doc/build.scm")
- (environment-variables
- '(("GUIX_MANUAL" . "guix-cookbook")
- ("GUIX_WEB_SITE_URL" . "/")))))
+ (build-file "doc/build.scm")
+ (environment-variables
+ '(("GUIX_MANUAL" . "guix-cookbook")
+ ("GUIX_WEB_SITE_URL" . "/"))))))
;; TODO: Add the manuals of Cuirass and GWL.
;; The bootstrappable.org web site.
(service static-web-site-service-type
- (static-web-site-configuration
- (git-url
- "https://git.savannah.gnu.org/git/guix/bootstrappable.git")
- (period (* 24 3600)) ;check once per day
- (directory "/srv/bootstrappable.org")))
+ (list (static-web-site-configuration
+ (git-url
+ "https://git.savannah.gnu.org/git/guix/bootstrappable.git")
+ (period (* 24 3600)) ;check once per day
+ (directory "/srv/bootstrappable.org"))))
;; GWL web site.
(service gwl-web-service-type)))
- branch master updated (e19f6d9 -> 601691e), Ludovic Courtès, 2021/12/22
- 05/06: hydra: web: 'static-web-site-service-type' is extensible., Ludovic Courtès, 2021/12/22
- 02/06: Revert "bayfront: Use substitutes from berlin.", Ludovic Courtès, 2021/12/22
- 06/06: hydra: web: Provide all-in-one 'guix-web-site-service-type'., Ludovic Courtès, 2021/12/22
- 01/06: hydra: bayfront: Remove 'disarchive-service-type' instance., Ludovic Courtès, 2021/12/22
- 04/06: hydra: web: 'static-web-site-service-type' handles lists of sites.,
Ludovic Courtès <=
- 03/06: hydra: Add (sysadmin nginx) module., Ludovic Courtès, 2021/12/22