diff options
Diffstat (limited to 'guix-data-service/web/server.scm')
-rw-r--r-- | guix-data-service/web/server.scm | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/guix-data-service/web/server.scm b/guix-data-service/web/server.scm index 05c0a58..599288c 100644 --- a/guix-data-service/web/server.scm +++ b/guix-data-service/web/server.scm @@ -24,12 +24,22 @@ #:use-module (web request) #:use-module (web uri) #:use-module (system repl error-handling) + #:use-module (ice-9 atomic) #:use-module (fibers web server) #:use-module (guix-data-service web controller) #:use-module (guix-data-service web util) #:export (start-guix-data-service-web-server)) -(define (handler request body controller secret-key-base) +(define (check-startup-completed startup-completed) + (if (atomic-box-ref startup-completed) + (begin + ;; Just in case this atomic-box-ref is expensive, only do it when + ;; necessary + (set! check-startup-completed (const #t)) + #t) + #f)) + +(define (handler request body controller secret-key-base startup-completed) (display (format #f "~a ~a\n" (request-method request) @@ -42,14 +52,17 @@ request-components) mime-types body - secret-key-base)))) + secret-key-base + (check-startup-completed startup-completed))))) -(define* (start-guix-data-service-web-server port host secret-key-base) +(define* (start-guix-data-service-web-server port host secret-key-base + startup-completed) (call-with-error-handling (lambda () (run-server (lambda (request body) (handler request body controller - secret-key-base)) + secret-key-base + startup-completed)) #:host host #:port port)) #:on-error 'backtrace |