How to run in Nodejs parallel process but limit the number of process that exist in the current bulk?
Example, I have an Array with 200 items ['word.doc', 'foo.pdf', 'a.txt', ...]
and I need to run Work process for each item like so:
Work.exe word.doc
Work.exe foo.pdf
Work.exe a.txt
Work.exe ....
What I did is:
forEach
in the Array..- call to
exec
fromchild_process
lib.
But I want only 5 process each time. When some process will end a new item should be up and running. So every time I have only 5 process until all process are completed.
Not sure how it can be done.