From f245656c0cde9cf88f4b7217dec3dce6dce647a7 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Fri, 31 Jan 2020 19:12:58 +0100 Subject: [PATCH] :sparkles: Add a proper way to enable/disable assertions on clojure code. --- backend/src/uxbox/main.clj | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/backend/src/uxbox/main.clj b/backend/src/uxbox/main.clj index b8e6fc3e3..8880c6d51 100644 --- a/backend/src/uxbox/main.clj +++ b/backend/src/uxbox/main.clj @@ -9,16 +9,24 @@ (ns uxbox.main (:require - [mount.core :as mount] - [uxbox.config :as cfg] - [uxbox.migrations] - [uxbox.db] - [uxbox.http] - #_[uxbox.scheduled-jobs]) - (:gen-class)) + [mount.core :as mount])) + +(defn- enable-asserts + [_] + (let [m (System/getProperty "uxbox.enable-asserts")] + (or (nil? m) (= "true" m)))) + +;; Set value for current thread binding. +(set! *assert* (enable-asserts nil)) + +;; Set value for all new threads bindings. +(alter-var-root #'*assert* enable-asserts) ;; --- Entry point (defn -main [& args] + (load "uxbox/config" + "uxbox/migrations" + "uxbox/http") (mount/start))