tools-deps

Discuss tools.deps.alpha, tools.build, and the clj/clojure command-line scripts! See also #depstar #clj-new
ingesol 2021-04-07T13:04:17.387600Z

Hi! Is there a known pattern in tools.deps for loading/running multiple processes in parallel, like CLJS-build, SASS build, reloadable CLJ-system?

alexmiller 2021-04-07T13:10:16.388Z

the Clojure CLI runs one program

alexmiller 2021-04-07T13:10:35.388500Z

if you want to run multiple things, then you need to make something that does that

tvaughan 2021-04-07T13:14:09.389100Z

Perhaps your looking for something like https://devcenter.heroku.com/articles/procfile?

borkdude 2021-04-07T13:34:57.390Z

@ingesol We use this (bb) script at work for launching these three things at once:

#!/usr/bin/env bb

(ns dev)

(require '[babashka.process :refer [destroy-tree process]])

(def opts {:out :inherit
           :err :inherit
           :shutdown destroy-tree})

(defn cljs []
  (process ["clojure" "-Sforce" "-M:frontend:cljs/dev"] opts))

(defn less []
  (process ["clojure" "-Sforce" "-M:frontend:less/dev"] opts))

(def platform-alias
  (case (System/getProperty "os.name")
    "Linux"
    "backend/linux"
    "Windows"
    "backend/windows"
    "Mac OS X"
    "backend/macosx"))

(defn clojure []
  (process ["clojure" "-Sforce"
            (str "-A:backend:backend/dev:" platform-alias)
            "-X" "dre.standalone/start"]
           (assoc opts :in :inherit)))

(cljs)
(less)
(-> @(clojure) :exit (System/exit))

2❤️
ingesol 2021-04-07T13:53:00.390800Z

Thanks! That is one option, yes. I was mostly wondering if this was a common problem with well known patterns for people who use tools.deps.

1👍
ingesol 2021-04-07T13:53:37.391Z

That is lovely, thanks

ingesol 2021-04-07T13:57:54.391200Z

Right, that’s what I suspected. I also was hoping that the community had established some patterns for solving this kind of problems. My first idea was to just create a CLJ-script that I could invoke from the CLI, that would simply start those processes. @borkdude provided a bb-technique below, I suppose that is preferable to a JVM script as it leans on OS features for shutdown.

ingesol 2021-04-07T13:58:42.391400Z

or at least it seems that the bb-script saves me from having to think about graceful shutdown.

2021-04-07T15:36:07.393200Z

does anyone have an example of using -J to pass JVM options from the command line in conjunction with -M ? I can get it to work if I put :jvm-opts into deps.edn directly but I’d rather these be specified by people at the command line, and can’t figure out how to do that

alexmiller 2021-04-07T15:39:09.393500Z

you just -J-Dfoo=bar on the command line

alexmiller 2021-04-07T15:39:39.393800Z

what did you try?

seancorfield 2021-04-07T15:41:15.394600Z

-J must come before -M (otherwise it will be treated as a command-line arg to what you are running).

1☝️
2021-04-07T15:42:21.395Z

aha, that was it, and I guess multiple options need -J multiple times

2021-04-07T15:42:29.395300Z

tired putting everything into one quoted string and that wasn’t working

2021-04-07T15:42:58.395500Z

as the docs state 😆

2021-04-07T15:44:10.395700Z

anyways, thanks to both of you

borkdude 2021-04-07T18:35:41.396Z

Our projects at work are now fully deps.edn-ized, no more boot. Migration complete.

12🎉
seancorfield 2021-04-07T18:40:00.396900Z

Welcome to the future @borkdude! 🙂

unbalanced 2021-04-07T22:05:01.397600Z

you work on top of all your opensource stuff!? I figured you'd be FT open source by now!!

borkdude 2021-04-07T22:09:28.398Z

if I got paid to do full time open source, I maybe would. but currently I get sponsored for about 1/5th - 1/4th of what I would need to make that jump. even then, I do like to be grounded in "reality" to get a feel for what the real problems are.