aboutsummaryrefslogtreecommitdiff
path: root/bffe/server.scm
diff options
context:
space:
mode:
Diffstat (limited to 'bffe/server.scm')
-rw-r--r--bffe/server.scm52
1 files changed, 28 insertions, 24 deletions
diff --git a/bffe/server.scm b/bffe/server.scm
index 9d6a4a1..0816b0f 100644
--- a/bffe/server.scm
+++ b/bffe/server.scm
@@ -482,30 +482,34 @@
(lambda ()
(run-fibers
(lambda ()
- (let* ((initial-state-id
- (assoc-ref
- (get-state state-channel)
- "state_id"))
- (events-channel
- get-state-id
- (make-events-channel
- initial-state-id))
- (controller
- (apply make-controller assets-directory
- metrics-registry
- events-channel state-channel
- controller-args)))
-
- ;; Wait until the events channel catches up
- (while (< (get-state-id) initial-state-id)
- (sleep 10))
-
- (simple-format #t "Starting the server\n")
- (run-server/patched (lambda (request body)
- (apply values
- (handler request body controller)))
- #:host host
- #:port port))
+ (let ((initial-state-id
+ (assoc-ref
+ (get-state state-channel)
+ "state_id")))
+ (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))
+ (controller
+ (apply make-controller assets-directory
+ metrics-registry
+ events-channel state-channel
+ controller-args)))
+
+ ;; Wait until the events channel catches up
+ (while (< (get-state-id) initial-state-id)
+ (sleep 1))
+
+ (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?))))
finished?)))