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
No related merge requests found
......@@ -5,7 +5,7 @@
(use-modules (gnu)
(srfi srfi-1))
(use-service-modules admin avahi base cuirass mcron networking
ssh virtualization)
shepherd ssh virtualization)
(use-package-modules certs screen ssh)
(use-modules ((cuirass-package) #:prefix latest:))
......@@ -36,16 +36,40 @@
;; We have 24 to 32 cores.
(extra-options '("--max-jobs=4" "--cores=8"))))))
(define garbage-collector-jobs
;; Collect garbage several times a day, with a bigger collection at 5AM.
(list #~(job '(next-hour '(5))
"guix gc -F 50G -d 2m")
#~(job '(next-hour '(10))
"guix gc -F 15G")
#~(job '(next-hour '(15))
"guix gc -F 25G")
#~(job '(next-hour '(20))
"guix gc -F 15G")))
(define (garbage-collector-service name calendar free-space)
"Return a Shepherd timer called NAME that collects garbage according to
CALENDAR, a gexp, and ensures at least FREE-SPACE GiB are available."
(simple-service
name shepherd-root-service-type
(list (shepherd-service
(provision (list name))
(requirement '(user-processes))
(modules '((shepherd service timer)))
(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
......@@ -103,8 +127,6 @@
(platforms (lookup-qemu-platforms "arm"
"aarch64"
"ppc64le"
"riscv64"))))
(simple-service 'gc-jobs mcron-service-type
garbage-collector-jobs))
"riscv64")))))
%garbage-collector-services
%custom-base-services)))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment