diff options
author | Christopher Baines <mail@cbaines.net> | 2023-04-24 10:46:36 +0100 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2023-04-24 10:46:36 +0100 |
commit | 5180a77cf8dbc4f6134b19aa2a6d7c8dc70269e7 (patch) | |
tree | fa4a1b1fa13748aef9f7e1d1858f4e3ca96feb67 | |
parent | 91d0f2177212ee145bae122a5c0c315b4e184bb3 (diff) | |
download | bffe-5180a77cf8dbc4f6134b19aa2a6d7c8dc70269e7.tar bffe-5180a77cf8dbc4f6134b19aa2a6d7c8dc70269e7.tar.gz |
Tune the server startup
-rw-r--r-- | bffe/server.scm | 52 |
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?))) |