Fork me on GitHub
#dirac
<
2016-03-11
>
smw04:03:05

(defn start-dirac! []
  (require 'dirac.agent)
  (let [dirac-boot! (resolve 'dirac.agent/boot!)]
    (dirac-boot!)))

(deftask dirac
  "run dirac agent"
  [] 
  (with-pre-wrap fileset
    (start-dirac!)
    fileset))

smw04:03:30

That’s a first pass at it. with-pre-wrap is boot.core/with-pre-wrap

smw06:03:16

Is this typical behavior? Gives me undefined variable, though it’s obviously able to call the function?

smw06:03:22

Never mind, found the problem under github issues. Must (require ‘my.ns).

jaen12:03:38

But won't doing start-dirac! try to start it each time you re-run the pipeline (like when you watch and something changes?). I don't think that call is idempotent so it could be a problem.

smw18:03:17

@jaen you appear to be exactly right. Does putting it before (watch) fix that?

smw18:03:48

Or do I need to do something like inject a file into the fileset and check that to ensure idempotency?

jaen20:03:53

Both options sound like hacks to me instead of solving the problem TBH.

jaen20:03:54

I just type (start-dirac!) manually each time and don't mind it, but I can see how it could be a bother.

jaen20:03:02

There was this one thing, let me check…

jaen20:03:57

:eval option

jaen20:03:13

I tried to use this, since it seemed like the most appropriate solution

jaen20:03:21

But I couldn't get it to work for some reason.

jaen20:03:29

I suggest asking on the #C053K90BR channel about that

jaen20:03:54

There certainly must be an appropriate way to inject some code to run when the REPL server boots

jaen20:03:08

I thought it was that, but maybe I did something wrong.

jaen20:03:26

Though now I checked #C053K90BR I see they suggested using delay, that also sounds sensible.

smw20:03:19

(deftask dirac
  "run dirac agent"
  []
  (let [dirac (delay (start-dirac!))]
    (cleanup (.stop @dirac))
    (with-pass-thru _ @dirac)))

smw20:03:40

that lets you use it the same way you’d use (cljs-repl)

smw20:03:58

I’ll see if I can make a redistributable boot task.

jaen20:03:02

Well, it's not much of a problem to evaluate one form at the start of the session (that's why I didn't bother after :eval didn't work out), but if that can be automated then - why not!

jaen20:03:07

It's always one less thing to remember.

smw20:03:07

Yep. I think if it were just me, I might consider living with the extra thing to type

smw20:03:37

but tooling is so important for adoption, in my opinion. Even among developers, the number of people who won’t read directions is staggering.