node-process-pool
v0.6.1
Published
a process pool for Node.js
Downloads
10
Maintainers
Readme
Node Process Pool
If you want to learn more, please visit ProcessPool in github.
Installation
npm install node-process-pool
Usage
// Process pool usage example
const ProcessPool = require('node-process-pool')
const taskParams = []
for (let i = 0; i < 5000; i++) {
taskParams[i] = [i]
}
// Create a process pool instance
const processPool = new ProcessPool({
maxParallelProcess: 50, // Supports maximum number of process parallelism
timeToClose: 60 * 1000, // The maximum time for a single task to be executed
dependency: `const path = require('path')`, // task script dependencies
workDir: __dirname, // current directory
taskName: 'test', // task script name
script: async function task(taskParams) {
console.log(taskParams)
},
taskParams // Need to perform the task parameter list, two-dimensional array
})
// Process pools are used to handle large scale tasks
processPool.run()