aboutsummaryrefslogtreecommitdiff
path: root/bffe/server.scm
diff options
context:
space:
mode:
Diffstat (limited to 'bffe/server.scm')
-rw-r--r--bffe/server.scm100
1 files changed, 46 insertions, 54 deletions
diff --git a/bffe/server.scm b/bffe/server.scm
index 79376d6..ff36a44 100644
--- a/bffe/server.scm
+++ b/bffe/server.scm
@@ -50,7 +50,7 @@
call-with-delay-logging
retry-on-error))
#:use-module ((guix-build-coordinator utils fibers)
- #:select (run-server/patched call-with-sigint))
+ #:select (run-server/patched))
#:use-module (guix-build-coordinator client-communication)
#:use-module (bffe config)
#:use-module (bffe view util)
@@ -58,7 +58,9 @@
#:use-module (bffe view build)
#:use-module (bffe view agent)
#:use-module (bffe view activity)
- #:export (start-bffe-web-server))
+ #:export (http-get*
+
+ start-bffe-web-server))
;; TODO Work around this causing problems with backtraces
;; https://github.com/wingo/fibers/issues/76
@@ -600,55 +602,45 @@
pid-file
metrics-registry)
- (let ((finished? (make-condition)))
- (call-with-sigint
- (lambda ()
- (run-fibers
- (lambda ()
- (let* ((state-channel
- (make-state-channel
- event-source))
- (initial-state-id
- (retry-on-error
- (lambda ()
- (assoc-ref
- (get-state state-channel)
- "state_id"))
- #:times 6
- #:delay 10)))
- (simple-format #t "Starting from state ~A\n"
- initial-state-id)
-
- (let* ((events-channel
- get-state-id
- (make-events-channel
- event-source
- initial-state-id
- #:metrics-registry metrics-registry))
- (controller
- (apply make-controller assets-directory
- metrics-registry
- events-channel state-channel
- event-source
- controller-args)))
-
- ;; Wait until the events channel catches up
- (while (< (get-state-id) initial-state-id)
- (sleep 1))
-
- (when pid-file
- (call-with-output-file pid-file
- (lambda (port)
- (simple-format port "~A\n" (getpid)))))
-
- (simple-format #t "Starting the server\n")
- (run-server/patched (lambda (request body)
- (apply values
- (handler request body controller)))
- #:host host
- #:port port)))
-
- (wait finished?))
- #:hz 10
- #:parallelism 4))
- finished?)))
+ (let* ((state-channel
+ (make-state-channel
+ event-source))
+ (initial-state-id
+ (retry-on-error
+ (lambda ()
+ (assoc-ref
+ (get-state state-channel)
+ "state_id"))
+ #:times 6
+ #:delay 10)))
+ (simple-format #t "Starting from state ~A\n"
+ initial-state-id)
+
+ (let* ((events-channel
+ get-state-id
+ (make-events-channel
+ event-source
+ initial-state-id
+ #:metrics-registry metrics-registry))
+ (controller
+ (apply make-controller assets-directory
+ metrics-registry
+ events-channel state-channel
+ event-source
+ controller-args)))
+
+ ;; Wait until the events channel catches up
+ (while (< (get-state-id) initial-state-id)
+ (sleep 1))
+
+ (when pid-file
+ (call-with-output-file pid-file
+ (lambda (port)
+ (simple-format port "~A\n" (getpid)))))
+
+ (simple-format #t "Starting the server\n")
+ (run-server/patched (lambda (request body)
+ (apply values
+ (handler request body controller)))
+ #:host host
+ #:port port))))