I have one process generating data files in a folder, about one new file every 10 seconds.
I have another nodeJS watcher, monitoring the directory, as new files coming in.
const watcher = chokidar.watch(['data_folder']);
watcher.on('add', (path, stats)=>{
if (stats && stats.size > 0){
console.log(path);
//spawn child_process to do further processing
spawn_child_process_to_run(path);
}
});
The new files are then further processed by child_process, which can take quite a long time to finish.
The question is how to queue the files, so that they can be processed in parallel, without hitting the number limits of nodeJS child process.