component

oliver 2020-11-23T10:22:34.003900Z

Hi, anyone here using Steven Collins' https://github.com/lomin/component-restart ? I'm using it pretty much the way it apparently is supposed to: (defn -main [& args] (println "Starting the system. With restart watcher.") (let [started (sys/start (system/example-system {}))] (restart/watch (var -main) started))) Once I call (-main) from my CIDER-REPL the system starts and reloading/restarting works pretty much as advertised. My REPL however is stuck in some evaluation, so I cannot evaluate anything inside my buffers. Any idea on how to investigate this?

seancorfield 2020-11-23T18:09:20.005300Z

If you call (future (-main)) it should execute on a thread and leave your REPL unblocked.

seancorfield 2020-11-23T18:09:50.005700Z

(but then you can't easily stop the background process)

seancorfield 2020-11-23T18:11:53.008Z

My recommendation is always: do not use watchers/reload machinery. Provide a top-level def for the system Component, and then alter-var-root .. component/start / alter-var-root .. component/stop on it manually as needed. Most folks have some convenience functions, sometimes in their user.clj file, that wrap that in simple start / stop functions @services

seancorfield 2020-11-23T18:12:56.009Z

(and if you are careful with function var references, you shouldn't need to restart your component system at all: just start it once and then eval every change you make into the running program)

oliver 2020-11-23T20:06:50.017100Z

Why am I not surprised to hear you discourage the use of automatic reloading 😉 … I had actually tried using future (and thread) myself but I tried wrapping just the (restart/watch (var -main) started) part, which didn't work… your solution works better but gives me no more than your second approach would (probably due to some quirk with the template I'm trying to get working here) I have, however, gotten your second approach to work successfully… and it's more than enough. Many thanks for your help on this occasion (and previous ones). Cheers!

1