Fork me on GitHub
#duct
<
2022-07-13
>
Yehonathan Sharvit06:07:04

@kevin.van.rooijen What a good place to manually save the state in an atom?

Kevin06:07:56

I just created a db.clj or config.clj file and stored it there (with defonce)

Kevin09:07:06

Sorry, I literally can't because I don't work for that company anymore and don't have access to the code 😅 But something along these lines:

(ns simple.main
  (:gen-class)
  (:require [duct.core :as duct]))

(defonce stored-config (atom nil))
(defonce stored-system (atom nil))

(duct/load-hierarchy)

(defn -main [& args]
  (let [keys     (or (duct/parse-keys args) [:duct/daemon])
        profiles [:duct.profile/prod]
        config (-> (duct/resource "simple/config.edn")
                   (duct/read-config)
                   (duct/prep-config profiles))
        system (ig/init config keys)]
    (reset! stored-config config)
    (reset! stored-system system)
    (duct/await-daemons system)))