duct

Yehonathan Sharvit 2022-07-13T06:16:04.171859Z

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

2022-07-13T06:16:56.481109Z

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

Yehonathan Sharvit 2022-07-13T09:33:55.855629Z

@kevin.van.rooijen Can you show me your code?

2022-07-13T09:42:06.936629Z

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)))

Yehonathan Sharvit 2022-07-13T13:10:33.571599Z

I see. Thank you!