-
Hi everyone, I would like to run several processes in parallel from a bb script. All processes produce real time output which I would like to print in real time using std out/err for monitoring similar to this discussion. To run multiple dependent tasks in parallel I simply use the bb taskrunner. Now the question: Is there a way to inject a marker for each process output at the beginning of each line that is written to out/err by a process? I.e. i have two tasks, each tasks spawns a process like
Ideally with the ability to set a specific color for each marker. I guess It should be possible by piping the output of one process to another and modifying the output/stream content in the middle. But in my opinion this is quite an overhead and not very elegant. I also tried to use the streaming output example as a starting point but for some reason I'm not getting anything printed to my terminal at all. Still I guess that might be the way to go. Or is there any better way that I'm missing? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 12 replies
-
We have an issue for that here: #54 |
Beta Was this translation helpful? Give feedback.
-
@7tupel Here is a demo of how it might work: (ns proc-demo
(:require [babashka.process :as process :refer [process]]
[clojure.java.io :as io]))
(defn output-wrapper [proc prefix]
(let [stream (:out proc)
rdr (io/reader stream)
lines (line-seq rdr)]
(run! #(println prefix %) lines)))
(let [proc1 (process "ls")
proc2 (process "ls -la")]
(future (output-wrapper proc1 "[a]"))
(future (output-wrapper proc2 "[b]"))
@proc1
@proc2) |
Beta Was this translation helpful? Give feedback.
@7tupel Here is a demo of how it might work: