Conversation
| if (process) { | ||
| console.log(('Killing run #' + task.number).yellow); | ||
|
|
||
| // XXX: should we send SIGKILL or account for sub-processes somehow |
There was a problem hiding this comment.
i think killing the subprocesses should be a requirement. in my use cases, the subprocess ends up being /bin/sh, which launches npm, which launches another /bin/sh. sending SIGINT to the shell won't help kill the rest of the subprocesses. the 2 ways i found to work around this were to launch the subprocess in a process group, or to traverse the output of ps to kill each process. the first solution has issues on OS X. the second is abstracted nicely in npm module ps-tree. see #29 for more details.
|
@sw-double this looks really cool! i think it has a superset of the goals of the PR i made a few days earlier (#29). i'd be happy to see this land instead of mine if i saw some tests that verified the functionality works as intended. did you try it out in a project? |
|
I would love to see this get in. It'd make chokidar so useful for "live reloading" Express/Koa servers. @sw-double could you add a few tests so this gets merged? |
|
Any updates on this? |
Here is my take on concurrency based on async.queue and bluedird's cancellable promises. It represents shell commands as promises, which when cancelled would kill the underlying process. It also puts commands into the queue to allow fine-grained control over concurrency models.
I've also utilized exec-sh which abstracts away cross platform command execution and stdio stream forwarding.
This PR adds
--concurrencyoption with three possible concurrency model choices:kill(default): kills unfinished process before starting a new one. Example use case: assets compilation. For example if *.sass file changes you want to kill current build process and start a new one.queue: waits until previously started process is finished before starting a new one. Example use case: continuous rsync on file changes. If file changes during syncing you probably want to let rsync finish and run it once more after it's done.parallel: executes subsequent commands in parallel. I believe this option is how chokidar-cli works currently.Note that this PR needs some clean up before it is ready to merge. I'll clean it up and work on tests if you like this approach.