Skip to content

Monitor parallel processes/tasks with prefix in output #102

Answered by borkdude
7tupel asked this question in Q&A
Discussion options

You must be logged in to vote

@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)

Replies: 2 comments 12 replies

Comment options

You must be logged in to vote
1 reply
@borkdude
Comment options

Comment options

You must be logged in to vote
11 replies
@7tupel
Comment options

@borkdude
Comment options

@7tupel
Comment options

@borkdude
Comment options

@7tupel
Comment options

Answer selected by 7tupel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants