diff options
author | Christopher Baines <mail@cbaines.net> | 2025-02-15 22:34:26 +0000 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2025-02-15 22:34:26 +0000 |
commit | fa3a7d3d5e0fe3e277d63aae9ceabb1d059194b5 (patch) | |
tree | ebe14d2b3c403120b86a61b68c4a89e94d5ef4a5 | |
parent | 08688ef1b2402b15847b0fbf1e651872fd26b383 (diff) | |
download | build-coordinator-fa3a7d3d5e0fe3e277d63aae9ceabb1d059194b5.tar build-coordinator-fa3a7d3d5e0fe3e277d63aae9ceabb1d059194b5.tar.gz |
Add a listen repl
To make it eaiser to access the running service.
-rw-r--r-- | guix-build-coordinator/coordinator.scm | 34 | ||||
-rw-r--r-- | scripts/guix-build-coordinator.in | 10 |
2 files changed, 42 insertions, 2 deletions
diff --git a/guix-build-coordinator/coordinator.scm b/guix-build-coordinator/coordinator.scm index 5d627d3..c45850a 100644 --- a/guix-build-coordinator/coordinator.scm +++ b/guix-build-coordinator/coordinator.scm @@ -39,6 +39,8 @@ #:use-module (ice-9 threads) #:use-module (ice-9 exceptions) #:use-module (rnrs bytevectors) + #:use-module (system repl server) + #:use-module (system repl command) #:use-module (system repl debug) #:use-module (web uri) #:use-module (web http) @@ -74,6 +76,8 @@ client-error? client-error-details + %build-coordinator + make-build-coordinator build-coordinator-datastore build-coordinator-hooks @@ -126,6 +130,9 @@ client-error? (details client-error-details)) +(define %build-coordinator + (make-parameter #f)) + (define-record-type <build-coordinator> (make-build-coordinator-record datastore hooks metrics-registry allocation-strategy allocator-channel @@ -473,6 +480,11 @@ (define %default-agent-uri (string->uri "http://0.0.0.0:8745")) (define %default-client-uri (string->uri "http://127.0.0.1:8746")) +(define %default-repl-server-port + ;; Default port to run REPL server on, if --listen-repl is provided + ;; but no port is mentioned + 37146) + (define* (run-coordinator-service build-coordinator #:key (update-datastore? #t) @@ -480,7 +492,8 @@ (agent-communication-uri %default-agent-uri) (client-communication-uri %default-client-uri) secret-key-base - (parallel-hooks '())) + (parallel-hooks '()) + (listen-repl #t)) (install-suspendable-ports!) (with-fluids ((%file-port-name-canonicalization 'none)) @@ -490,6 +503,25 @@ #:pid-file pid-file #:parallel-hooks parallel-hooks) + (when listen-repl + (parameterize ((%build-coordinator build-coordinator)) + (cond + ((or (eq? #t listen-repl) + (number? listen-repl)) + (format (current-error-port) + "REPL server listening on port ~a~%" + listen-repl) + (spawn-server (make-tcp-server-socket + #:port + (if (eq? #t listen-repl) + %default-repl-server-port + listen-repl)))) + (else + (format (current-error-port) + "REPL server listening on ~a~%" + listen-repl) + (spawn-server (make-unix-domain-server-socket #:path listen-repl)))))) + ;; Create some worker thread channels, which need to be created prior ;; to run-fibers being called. (let ((output-hash-channel diff --git a/scripts/guix-build-coordinator.in b/scripts/guix-build-coordinator.in index bdde9a9..a35074f 100644 --- a/scripts/guix-build-coordinator.in +++ b/scripts/guix-build-coordinator.in @@ -74,6 +74,13 @@ (option '("update-database") #f #f (lambda (opt name _ result) (alist-cons 'update-database #t result))) + (option '("listen-repl") #f #t + (lambda (opt name arg result) + (alist-cons 'listen-repl + (if arg + (string->number arg) + #t) + (alist-delete 'listen-repl result)))) (option '("show-error-details") #f #f (lambda (opt name _ result) (alist-cons 'show-error-details #t result))))) @@ -1101,4 +1108,5 @@ tags: #:pid-file (assq-ref opts 'pid-file) #:agent-communication-uri (assq-ref opts 'agent-communication) #:client-communication-uri (assq-ref opts 'client-communication) - #:parallel-hooks (assq-ref opts 'parallel-hooks))))))) + #:parallel-hooks (assq-ref opts 'parallel-hooks) + #:listen-repl (assoc-ref opts 'listen-repl))))))) |