kouphax / lein-cooper

Foreman style plugin for Leiningen for running long running dev tasks in parallel.
Eclipse Public License 1.0
61 stars 6 forks source link

Cooper runs all processes (but only shows one)?! #12

Open holyjak opened 5 years ago

holyjak commented 5 years ago

First of all, thank you for the plugin!

I see something that surprises me: I have defined 3 processes, asked cooper to start one and it seems it did - but when I look at running system processes, I see all running. Is that to be expected? See:

# This is as expected
๐ŸŸ  lein cooper less
11:44:56 less | Compiling {less} css:
11:44:56 less | Found {less} source paths:
11:44:56 less |   src/less
11:44:56 less | Watching for changes...
11:44:56 less | src/less/print.less => resources/public/css/print.css
11:44:58 less | src/less/variables.less => resources/public/css/variables.css
11:44:58 less | src/less/screen.less => resources/public/css/screen.css
11:44:59 less | src/less/styleguide-overrides.less => resources/public/css/styleguide-overrides.css

# This, in another terminal, is not
# 1. Before starting cooper, there was nothing:
๐ŸŸ  ps | grep leiningen
35741 ttys000    0:00.00 grep --color=auto leiningen
# 2. After starting it, there is too much:
[master] ~/W/myapp๐ŸŸ  ps | grep leiningen
35810 ttys000    0:00.00 grep --color=auto leiningen
35773 ttys009    0:11.25 java -[..] clojure.main -m leiningen.core.main cooper less
35784 ttys009    0:16.81 java -[..] clojure.main -m leiningen.core.main run -e no-backend
35786 ttys009    0:21.49 java -[..] clojure.main -m leiningen.core.main less auto
35789 ttys009    0:22.21 java -[..] clojure.main -m leiningen.core.main minify-assets watch
# - why is here not only less (+ cooper less) but also run and minify-assets?!

This is the relevant part of my project.clj (I don't use Procfile):

...
:plugins [... [lein-cooper "1.2.2"]]
:cooper {"app" ["lein" "run" "-e" "no-backend"]
           "less" ["lein" "less" "auto"]
           "minify" ["lein" "minify-assets" "watch"]}

Is something wrong or is this as designed? Thank you!

holyjak commented 5 years ago

I guess that is because lein-coop calls sh/proc on all the processes at https://github.com/kouphax/lein-cooper/blob/c41207623df18975148ed63768b2c48862fc3573/src/leiningen/cooper.clj#L61 and only later decides which ones to pipe to its output at https://github.com/kouphax/lein-cooper/blob/c41207623df18975148ed63768b2c48862fc3573/src/leiningen/cooper.clj#L149

Shouldn't it filter first and only later start the processes?

I can create a PR for that ...