Is it possible to halt a single service (for example the http server)? I cannot seem to find a straightforward way of doing this..
I think something like (ig/halt! system [:duct/server])
?
Or do you mean on production?
No I am in development. Oh I didn't know that integrant/halt! accepts a vector of keys
will try
Ah thanks a lot
it worked!
👍
btw are there any docs on this? README doesn't seem to have it
https://github.com/weavejester/integrant#initializing-and-halting
"Both `init` and `halt!` can take a second argument of a collection of keys. If this is supplied, the functions will only initiate or halt the supplied keys (and any referenced keys)."
I seem to missed this
thanks!
I think init
halt!
suspend!
and resume
all take keys arguments
looks like this can't be done through integrant.repl 😞
Hmm, yeah looks like it
Try this:
(require ' [integrant.repl.state :as state])
(defn halt [keys]
(ig/halt! system keys)
(alter-var-root #'state/system (constantly nil))
:halted)
integrant repl halt doesn't seem to support keys https://github.com/weavejester/integrant-repl/blob/0b99db9447cd0d493ec811e10761f6331488f3d0/src/integrant/repl.clj#L68-L71
Maybe worth a PR
Also, it looks like init / go do have a keys option.
Hmm is it correct (in the reloaded workflow sense) to halt some keys but make state/system nil?
Yes it has a keys option but that has been committed 1 month ago and no release
Ah whoops, good catch. You don't want that to become nil
By the way, why do you want to only halt the server?
Because I wanted to test the disconnect/reconnect functionality for websockets in my web app and didn't want to close the shadow-cljs server (had a stale client error)
I think I have to find a workaround at the shadow-cljs part until we have selective halting in integrant.repl
I think you can just halt the system without modifying the state
Though I'm not entirely sure
Maybe ig/halt!
returns a new system, which you can use to replace the old one
Nevermind, halt just return nil
Yeah ig/halt!
returns nil and maybe this will be a blocking thing to incorporate selective halting in the reloaded workflow
but again I don't have a clear picture on the internals of integrant so maybe it could be done somehow
I think the problem will be that once you ig/init
the :duct/server
again, you'll have a partial system. You'd have to merge that back somehow
I don't think Integrant really support stopping / starting partially. I don't think stopping / starting is really a production feature either
(live reloading as a production feature, I mean)
Maybe suspend / resume would be an option for testing?
I'm not sure if that'll cause the desired reaction though