I'm using component
and for some reason, no combination of the following is running my latest changes
- component/stop
- clojure.tools.namespace.repl/refresh
(or (refresh :after ...)
)
- component/start
any idea what's up?
stop followed by refresh followd by start should work
i'm using this that I've found:
(defn go []
(init)
(start))
(defn reset []
(stop)
(refresh :after 'user/go))
but if you put any exclusive state (like eg. opening an http port) in the component, and called refresh before stop, then you are stuck
because the namespace has been teared down and deconstructed, so you no longer have a convenient handle to the thing monopolizing the resource
My usual repl recipe is:
(defn init!
[]
(log/info :msg "Initializing repl system")
(let [config (config/load-config)]
(alter-var-root #'system (constantly (system/assemble-system config)))))
(defn start!
[]
(when-not (:started? system)
(log/info :msg "Starting repl system")
(alter-var-root #'system system/start)))
(defn stop!
[]
(when (:started? system)
(log/info :msg "Stopping repl system")
(alter-var-root #'system system/stop)))
(defn restart!
[]
(stop!)
(start!))
(defn rebuild!
[]
(stop!)
(init!)
(start!))
it's weird, manually refresh
ing after a stop
seems to "find" my changed files, at least as far as what gets printed in the repl (cider)
but then... it still is running the old code.
and @donaldball that's basically what I have, pretty close to stuart sierra's recipe
I dunno, sorry, I don’t really tend to use tools.namespace
@josh.freckleton what if you use load-file
or require
with the :reload
arg, does that change things where refresh does not?
if so, it could be that tools.namespace is confused or misconfigured
@josh.freckleton sometimes I find tools.namespace gets really stuck and I have to call c.t.n.repl/clear to reset things
Also, are you using lein or boot?
@danielcompton I'm on lein, I'll have to look into clear
, thanks! It sounds like that's what's going on and I'm not sure why!
also reloaded.repl is great for standardising all of the behaviour above ^^
pretty much the same but nice to have in a library, at least I like it