Mentions légales du service

Skip to content
Snippets Groups Projects
Commit ca3b1fc0 authored by Ludovic Courtès's avatar Ludovic Courtès
Browse files

build-node: Run GC as Shepherd timers.

* build-node.scm (garbage-collector-jobs): Remove.
(garbage-collector-service): New procedure.
(%garbage-collector-services): New variable.
<top level>: Use them instead of the ‘mcron-service-type’ extension.
parent 0a255df3
No related branches found
No related tags found
Loading
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
(use-modules (gnu) (use-modules (gnu)
(srfi srfi-1)) (srfi srfi-1))
(use-service-modules admin avahi base cuirass mcron networking (use-service-modules admin avahi base cuirass mcron networking
ssh virtualization) shepherd ssh virtualization)
(use-package-modules certs screen ssh) (use-package-modules certs screen ssh)
(use-modules ((cuirass-package) #:prefix latest:)) (use-modules ((cuirass-package) #:prefix latest:))
...@@ -36,16 +36,40 @@ ...@@ -36,16 +36,40 @@
;; We have 24 to 32 cores. ;; We have 24 to 32 cores.
(extra-options '("--max-jobs=4" "--cores=8")))))) (extra-options '("--max-jobs=4" "--cores=8"))))))
(define garbage-collector-jobs (define (garbage-collector-service name calendar free-space)
;; Collect garbage several times a day, with a bigger collection at 5AM. "Return a Shepherd timer called NAME that collects garbage according to
(list #~(job '(next-hour '(5)) CALENDAR, a gexp, and ensures at least FREE-SPACE GiB are available."
"guix gc -F 50G -d 2m") (simple-service
#~(job '(next-hour '(10)) name shepherd-root-service-type
"guix gc -F 15G") (list (shepherd-service
#~(job '(next-hour '(15)) (provision (list name))
"guix gc -F 25G") (requirement '(user-processes))
#~(job '(next-hour '(20)) (modules '((shepherd service timer)))
"guix gc -F 15G"))) (start #~(make-timer-constructor
#$calendar
(command '("/run/current-system/profile/bin/guix" "gc"
"-F" #$(format #f "~aG" free-space)
"-d" "2m"))
#:wait-for-termination? #t))
(stop #~(make-timer-destructor))
(documentation "Run the garbage collector (GC).")
(actions
(list (shepherd-action
(name 'trigger)
(documentation "GC!")
(procedure #~trigger-timer))))))))
(define %garbage-collector-services
;; Collect garbage several times a day, with bigger collections twice a
;; day.
(list (garbage-collector-service 'gc-quick
#~(calendar-event #:minutes '(0)
#:hours '#$(iota 12 0 2))
15)
(garbage-collector-service 'gc
#~(calendar-event #:minutes '(0)
#:hours '(5 15))
50)))
(operating-system (operating-system
...@@ -103,8 +127,6 @@ ...@@ -103,8 +127,6 @@
(platforms (lookup-qemu-platforms "arm" (platforms (lookup-qemu-platforms "arm"
"aarch64" "aarch64"
"ppc64le" "ppc64le"
"riscv64")))) "riscv64")))))
%garbage-collector-services
(simple-service 'gc-jobs mcron-service-type
garbage-collector-jobs))
%custom-base-services))) %custom-base-services)))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment