Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Concurrently run multiple commands in parallel via single command definition #73

Open
roblav96 opened this issue Aug 26, 2020 · 2 comments
Labels
enhancement New feature or request

Comments

@roblav96
Copy link

@jakedeichert This is such a elegant step up from package.json scripts, you my friend are awesome!

Problem

Concurrently run multiple commands in parallel via one single mask command definition.

Example

Using npm-run-all --parallel in my package.json

"scripts": {
	"watch": "del dist; npm-run-all --silent --parallel watch:*",
	"watch:nodemon": "wait-for-change dist/index.js && delay 0.1 && nodemon dist/index.js",
	"watch:tsc": "tsc --watch --preserveWatchOutput",
},

I've tried all the alternative's at the bottom of your README.md and I haven't been able to find something that has implemented this feature.

So far mask is the best I've come across, then just shortly after.

Thanks friend! =]

@jacobdeichert
Copy link
Owner

Hey! Glad you're enjoying mask. just was one of my inspirations :)

So one option you have available is starting all your commands with bash in the background using &.

Here's a simple example:

## runall

~~~bash
$MASK run server & $MASK run client & $MASK run database
~~~

However, this gets a bit tricky... exiting mask will not close these background processes for you. There's ways to handle these background tasks like using bash traps but it becomes pretty verbose in my experience.

I personally would love a rust-based version of concurrently which is what I usually use for node projects. It's been on my todo list for awhile to make a rust version of that, but i'm not sure it directly falls into the scope of mask.

I'd want someone to build a cli/lib separately first, and then integrate that into mask so we can run tasks in parallel without users having to install another tool manually.

@jacobdeichert jacobdeichert added the enhancement New feature or request label Aug 28, 2020
@slavaGanzin
Copy link

@jacobdeichert it would be better with wait in the end.

## runall

~~~bash
$MASK run server & $MASK run client & $MASK run database & wait
~~~

However, this gets a bit tricky... exiting mask will not close these background processes for you. There's ways to handle these background tasks like using bash traps but it becomes pretty verbose in my experience.

For handling this case it's better to start another bash process inside bash process.

~~~bash
bash -c '$MASK run server & $MASK run client & $MASK run database & wait'
~~~

So when bash subprocess would be killed, it will automatically kill his child processes.
Didn't try this, just a suggestion. And yes, it looks ugly

p.s. For single-binary version of concurrently you could try my tool: https://github.com/slavaGanzin/await. It's written in C, so I think it's not what you are looking for

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants