diff --git a/src/xiana/hotreload.clj b/src/xiana/hotreload.clj new file mode 100644 index 00000000..65346fd0 --- /dev/null +++ b/src/xiana/hotreload.clj @@ -0,0 +1,56 @@ +(ns xiana.hotreload + (:require + [clojure.core.async :refer [go-loop system\". + (-> (config/config app-cfg) + ... + xiana.webserver/start + xiana.hotreload/hotreload) + If a :xiana/hotreload config key is provided it needs: + :restart-fn \"the function to restart the system\" if none 'user/start-dev-system + :tracker {:dirs \"the directories vector list to search for changes\" :reload-compile-errors? \"true\"}." + [cfg] + (let [{:keys [restart-fn tracker]} (:xiana/hotreload cfg) + dirs (:dirs tracker ["src"]) + retry? (:reload-compile-errors? tracker true) + track-fn (ns-tracker dirs) + reload! (reloader dirs retry?) + restart-fn (when restart-fn (resolve restart-fn))] + (when restart-fn + (go-loop [] + (