duct

g7s 2020-07-14T11:27:30.236200Z

Is it possible to halt a single service (for example the http server)? I cannot seem to find a straightforward way of doing this..

kwrooijen 2020-07-14T11:29:59.236700Z

I think something like (ig/halt! system [:duct/server]) ?

kwrooijen 2020-07-14T11:30:18.236900Z

Or do you mean on production?

g7s 2020-07-14T11:30:56.237600Z

No I am in development. Oh I didn't know that integrant/halt! accepts a vector of keys

g7s 2020-07-14T11:30:59.237800Z

will try

g7s 2020-07-14T11:31:38.238100Z

Ah thanks a lot

g7s 2020-07-14T11:31:41.238300Z

it worked!

kwrooijen 2020-07-14T11:32:34.238600Z

👍

g7s 2020-07-14T11:33:14.239200Z

btw are there any docs on this? README doesn't seem to have it

g7s 2020-07-14T11:34:11.239700Z

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

g7s 2020-07-14T11:34:29.240200Z

I seem to missed this

g7s 2020-07-14T11:34:31.240400Z

thanks!

kwrooijen 2020-07-14T11:36:10.241Z

I think init halt! suspend! and resume all take keys arguments

1👍
g7s 2020-07-14T12:05:06.242900Z

looks like this can't be done through integrant.repl 😞

kwrooijen 2020-07-14T12:07:59.243200Z

Hmm, yeah looks like it

kwrooijen 2020-07-14T12:08:54.243500Z

Try this:

(require ' [integrant.repl.state :as state])
(defn halt [keys]
  (ig/halt! system keys)
  (alter-var-root #'state/system (constantly nil))
  :halted)

kwrooijen 2020-07-14T12:09:17.243900Z

integrant repl halt doesn't seem to support keys https://github.com/weavejester/integrant-repl/blob/0b99db9447cd0d493ec811e10761f6331488f3d0/src/integrant/repl.clj#L68-L71

kwrooijen 2020-07-14T12:09:56.244200Z

Maybe worth a PR

kwrooijen 2020-07-14T12:12:11.244600Z

Also, it looks like init / go do have a keys option.

g7s 2020-07-14T12:12:51.245300Z

Hmm is it correct (in the reloaded workflow sense) to halt some keys but make state/system nil?

g7s 2020-07-14T12:13:16.245900Z

Yes it has a keys option but that has been committed 1 month ago and no release

kwrooijen 2020-07-14T12:20:20.246800Z

Ah whoops, good catch. You don't want that to become nil

kwrooijen 2020-07-14T12:20:33.247100Z

By the way, why do you want to only halt the server?

g7s 2020-07-14T12:32:18.249600Z

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)

g7s 2020-07-14T12:33:34.250600Z

I think I have to find a workaround at the shadow-cljs part until we have selective halting in integrant.repl

kwrooijen 2020-07-14T13:01:35.251100Z

I think you can just halt the system without modifying the state

kwrooijen 2020-07-14T13:02:01.251400Z

Though I'm not entirely sure

kwrooijen 2020-07-14T13:02:13.251600Z

Maybe ig/halt! returns a new system, which you can use to replace the old one

kwrooijen 2020-07-14T13:03:27.252100Z

Nevermind, halt just return nil

g7s 2020-07-14T13:22:21.255600Z

Yeah ig/halt! returns nil and maybe this will be a blocking thing to incorporate selective halting in the reloaded workflow

g7s 2020-07-14T13:23:37.256800Z

but again I don't have a clear picture on the internals of integrant so maybe it could be done somehow

kwrooijen 2020-07-14T14:54:57.258400Z

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

kwrooijen 2020-07-14T14:55:39.259400Z

I don't think Integrant really support stopping / starting partially. I don't think stopping / starting is really a production feature either

kwrooijen 2020-07-14T14:55:53.259700Z

(live reloading as a production feature, I mean)

kwrooijen 2020-07-14T14:57:02.260100Z

Maybe suspend / resume would be an option for testing?

kwrooijen 2020-07-14T14:57:30.260400Z

I'm not sure if that'll cause the desired reaction though