;;; Build Farm Front-End ;;; ;;; Copyright © 2023 Christopher Baines ;;; ;;; This program is free software: you can redistribute it and/or ;;; modify it under the terms of the GNU Affero General Public License ;;; as published by the Free Software Foundation, either version 3 of ;;; the License, or (at your option) any later version. ;;; ;;; This program is distributed in the hope that it will be useful, ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;; Affero General Public License for more details. ;;; ;;; You should have received a copy of the GNU Affero General Public ;;; License along with this program. If not, see ;;; . (define-module (bffe) #:use-module (ice-9 format) #:use-module (oop goops) #:use-module (prometheus) #:use-module (logging logger) #:use-module (logging port-log) #:use-module (fibers) #:use-module (fibers scheduler) #:use-module (fibers channels) #:use-module (fibers conditions) #:use-module ((guix-build-coordinator utils fibers) #:select (call-with-sigint)) #:use-module (bffe server) #:use-module (bffe manage-builds) #:export (run-bffe-service)) (define* (run-bffe-service #:key (metrics-registry (make-metrics-registry #:namespace "bffe")) (build '()) pid-file (web-server-args '())) (let ((lgr (make )) (port-log (make #:port (current-output-port) #:formatter (lambda (lvl time str) (format #f "~a (~5a): ~a~%" (strftime "%F %H:%M:%S" (localtime time)) lvl str))))) (setvbuf (current-output-port) 'line) (add-handler! lgr port-log) (open-log! lgr) (set-default-logger! lgr) (with-fluids ((%file-port-name-canonicalization 'none)) (let ((finished? (make-condition))) (call-with-sigint (lambda () (run-fibers (lambda () (for-each start-submit-builds-fibers build) (when web-server-args (apply start-bffe-web-server `(,@web-server-args #:pid-file ,pid-file #:metrics-registry ,metrics-registry))) (wait finished?)) #:hz 0 #:parallelism 1)) finished?)))))