Fork me on GitHub
#duct
<
2020-07-14
>
g7s11:07:30

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

kwrooijen11:07:59

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

kwrooijen11:07:18

Or do you mean on production?

g7s11:07:56

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

g7s11:07:59

will try

g7s11:07:38

Ah thanks a lot

g7s11:07:41

it worked!

g7s11:07:14

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

g7s11:07:11

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

g7s11:07:29

I seem to missed this

kwrooijen11:07:10

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

👍 3
g7s12:07:06

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

kwrooijen12:07:59

Hmm, yeah looks like it

kwrooijen12:07:54

Try this:

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

kwrooijen12:07:56

Maybe worth a PR

kwrooijen12:07:11

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

g7s12:07:51

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

g7s12:07:16

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

kwrooijen12:07:20

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

kwrooijen12:07:33

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

g7s12:07:18

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)

g7s12:07:34

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

kwrooijen13:07:35

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

kwrooijen13:07:01

Though I'm not entirely sure

kwrooijen13:07:13

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

kwrooijen13:07:27

Nevermind, halt just return nil

g7s13:07:21

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

g7s13:07:37

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

kwrooijen14:07:57

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

kwrooijen14:07:39

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

kwrooijen14:07:53

(live reloading as a production feature, I mean)

kwrooijen14:07:02

Maybe suspend / resume would be an option for testing?

kwrooijen14:07:30

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