🎉 Add health check api endpoint

This commit is contained in:
Andrey Antukh 2022-02-10 00:15:00 +01:00 committed by Alonso Torres
parent 3fbb440436
commit b591fbecf0
2 changed files with 10 additions and 2 deletions

View file

@ -150,8 +150,8 @@
[middleware/errors errors/handle]
[middleware/cookies]]}
["/health" {:get (:health-check debug)}]
["/_doc" {:get (doc/handler rpc)}]
["/feedback" {:middleware [(:middleware session)]
:post feedback}]
["/auth/oauth/:provider" {:post (:handler oauth)}]

View file

@ -18,9 +18,9 @@
[app.util.template :as tmpl]
[app.util.time :as dt]
[clojure.java.io :as io]
[fipp.edn :as fpp]
[cuerdas.core :as str]
[datoteka.core :as fs]
[fipp.edn :as fpp]
[integrant.core :as ig]))
;; (selmer.parser/cache-off!)
@ -194,9 +194,17 @@
:body (-> (io/resource "templates/error-list.tmpl")
(tmpl/render {:items items}))}))
(defn health-check
"Mainly a task that performs a health check."
[{:keys [pool]} _]
(db/with-atomic [conn pool]
(db/exec-one! conn ["select count(*) as count from server_prop;"])
{:status 200 :body "Ok"}))
(defmethod ig/init-key ::handlers
[_ cfg]
{:index (partial index cfg)
:health-check (partial health-check cfg)
:retrieve-file-data (partial retrieve-file-data cfg)
:retrieve-file-changes (partial retrieve-file-changes cfg)
:retrieve-error (partial retrieve-error cfg)