Return 503 for the /healthcheck if the service is starting up

As this is a little clearer.
This commit is contained in:
Christopher Baines 2022-07-15 09:24:46 +01:00
parent 1962b1f61c
commit ee73d2cc98

View file

@ -525,7 +525,7 @@
(define (startup-controller-thunk) (define (startup-controller-thunk)
(or (or
(base-controller request method-and-path-components) (base-controller request method-and-path-components #f)
(render-html (render-html
#:sxml (server-starting-up-page) #:sxml (server-starting-up-page)
#:code 503))) #:code 503)))
@ -542,7 +542,8 @@
#f)) #f))
#:code 500)))) #:code 500))))
(define (base-controller request method-and-path-components) (define* (base-controller request method-and-path-components
startup-completed?)
(match method-and-path-components (match method-and-path-components
(('GET "assets" rest ...) (('GET "assets" rest ...)
(or (handle-static-assets (string-join rest "/") (or (handle-static-assets (string-join rest "/")
@ -566,7 +567,9 @@
#:code (if (eq? database-status #:code (if (eq? database-status
#t) #t)
200 200
500)))) (if startup-completed?
500
503)))))
(('GET "README") (('GET "README")
(let ((filename (string-append (%config 'doc-dir) "/README.html"))) (let ((filename (string-append (%config 'doc-dir) "/README.html")))
(if (file-exists? filename) (if (file-exists? filename)
@ -612,7 +615,7 @@
#:code 404))) #:code 404)))
(or (or
(base-controller request method-and-path-components) (base-controller request method-and-path-components #t)
(match method-and-path-components (match method-and-path-components
(('GET) (('GET)
(render-html (render-html