From 4f17609b377c128888be6d85af46fb05fe38ce45 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Wed, 16 Sep 2020 20:46:54 +0100 Subject: Move more coordinator service startup out of the script --- guix-build-coordinator/coordinator.scm | 20 ++++++++++++++++++++ scripts/guix-build-coordinator.in | 15 ++++----------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/guix-build-coordinator/coordinator.scm b/guix-build-coordinator/coordinator.scm index c8727c8..a38045b 100644 --- a/guix-build-coordinator/coordinator.scm +++ b/guix-build-coordinator/coordinator.scm @@ -42,6 +42,8 @@ build-coordinator-metrics-registry build-coordinator-allocation-strategy + perform-coordinator-service-startup + submit-build new-agent new-agent-password @@ -82,8 +84,26 @@ build-coordinator (make-build-allocator-thread build-coordinator)) + (start-hook-processing-threads build-coordinator) + build-coordinator)) +(define* (perform-coordinator-service-startup build-coordinator + #:key + (update-datastore? #t) + (pid-file #f) + (trigger-build-allocation? #t)) + (when update-datastore? + (datastore-update (build-coordinator-datastore build-coordinator))) + + (when pid-file + (call-with-output-file pid-file + (lambda (port) + (simple-format port "~A\n" (getpid))))) + + (when trigger-build-allocation? + (trigger-build-allocation build-coordinator))) + (define* (submit-build build-coordinator derivation-file #:key requested-uuid diff --git a/scripts/guix-build-coordinator.in b/scripts/guix-build-coordinator.in index 8aed241..59341cc 100644 --- a/scripts/guix-build-coordinator.in +++ b/scripts/guix-build-coordinator.in @@ -420,14 +420,10 @@ processed?: ~A #:allocation-strategy (assq-ref opts 'allocation-strategy)))) - (when (assoc-ref opts 'update-database) - (datastore-update datastore)) - - (let ((pid-file (assq-ref opts 'pid-file))) - (when pid-file - (call-with-output-file pid-file - (lambda (port) - (simple-format port "~A\n" (getpid)))))) + (perform-coordinator-service-startup + build-coordinator + #:update-datastore? (assoc-ref opts 'update-database) + #:pid-file (assq-ref opts 'pid-file)) (parameterize ((%show-error-details (assoc-ref opts 'show-error-details))) @@ -443,9 +439,6 @@ processed?: ~A (make-worker-thread-channel (const '()) #:parallelism 2))) - (start-hook-processing-threads build-coordinator) - (trigger-build-allocation build-coordinator) - (let ((finished? (make-condition))) (call-with-sigint (lambda () -- cgit v1.2.3