aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2020-09-16 20:28:25 +0100
committerChristopher Baines <mail@cbaines.net>2020-09-16 21:00:08 +0100
commit10cfe37bd23848fb7901371b676358d711234e8c (patch)
treeefd3a05278ea99771bd438896dc7f9cb138a9a96
parent2ef1ccdc252eaf6fca949aa36f8eb6b5fd4862e6 (diff)
downloadbuild-coordinator-10cfe37bd23848fb7901371b676358d711234e8c.tar
build-coordinator-10cfe37bd23848fb7901371b676358d711234e8c.tar.gz
Refactor the fibers server starting code
More clearly split out the things that need to happen prior to run-fibers, and the things that can happen after.
-rw-r--r--scripts/guix-build-coordinator.in71
1 files changed, 35 insertions, 36 deletions
diff --git a/scripts/guix-build-coordinator.in b/scripts/guix-build-coordinator.in
index c7fbb1a..71111c0 100644
--- a/scripts/guix-build-coordinator.in
+++ b/scripts/guix-build-coordinator.in
@@ -467,51 +467,50 @@ processed?: ~A
(parameterize ((%show-error-details
(assoc-ref opts 'show-error-details)))
- (let* ((agent-communication-thunk
- (let ((agent-communication-uri
- (assq-ref opts 'agent-communication)))
- (match (uri-scheme agent-communication-uri)
- ('http
- (let ((host (uri-host agent-communication-uri))
- (port (uri-port agent-communication-uri))
- (chunked-request-channel
- ;; There are fibers issues when trying to read the
- ;; chunked requests
- (make-worker-thread-channel (const '())
- #:parallelism 8)))
- (lambda ()
- (simple-format #t "listening on ~A:~A\n"
- host port)
+ ;; Create some worker thread channels, which need to be created prior
+ ;; to run-fibers being called.
+ (let ((chunked-request-channel
+ ;; There are fibers issues when trying to read the chunked
+ ;; requests, so do this in dedicated threads.
+ (make-worker-thread-channel (const '())
+ #:parallelism 8))
+ (substitutes-channel
+ (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 ()
+ (run-fibers
+ (lambda ()
+ ;; Start the agent messaging server
+ (let ((agent-communication-uri
+ (assq-ref opts 'agent-communication)))
+ (match (uri-scheme agent-communication-uri)
+ ('http
+ (let ((host (uri-host agent-communication-uri))
+ (port (uri-port agent-communication-uri)))
(http-agent-messaging-start-server
port
host
(assq-ref opts 'secret-key-base)
build-coordinator
- chunked-request-channel)))))))
- (client-communication-thunk
- (let ((client-communication-uri
- (assq-ref opts 'client-communication))
- (substitutes-channel
- (make-worker-thread-channel (const '())
- #:parallelism 2)))
- (lambda ()
+ chunked-request-channel)
+ (simple-format #t "listening on ~A:~A\n"
+ host port)))))
+
+ ;; Start the client messaging server
+ (let ((client-communication-uri
+ (assq-ref opts 'client-communication)))
(start-client-request-server
(assq-ref opts 'secret-key-base)
(uri-host client-communication-uri)
(uri-port client-communication-uri)
build-coordinator
- substitutes-channel)))))
-
- (start-hook-processing-threads build-coordinator)
- (trigger-build-allocation build-coordinator)
-
- (let ((finished? (make-condition)))
- (call-with-sigint
- (lambda ()
- (run-fibers
- (lambda ()
- (agent-communication-thunk)
- (client-communication-thunk)
+ substitutes-channel))
(wait finished?))))
- finished?)))))))
+ finished?))))))))))