How to use the worker-farm.threaded function in worker-farm

To help you get started, we’ve selected a few worker-farm examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github linkfy / Tools-for-Instagram / src / executeWorker.js View on Github external
function executeWorker(args={}) {
    
    let {workerName = null, accountLoginFile = null, timeout = Infinity, extraParameters = {}} = args;
    
    
    timeout = timeout * 1000;
    let worker = workerFarm.threaded({maxCallTime: timeout},require.resolve(process.env.PWD+'/bots/workers/'+ workerName +'.js'));
    
    return new Promise(function(resolve, reject) {
        worker(accountLoginFile, function(err, result) {
            workerFarm.end(worker);
            resolve(result);    
        });
    });
    
    
}

worker-farm

Distribute processing tasks to child processes with an über-simple API and baked-in durability & custom concurrency options.

MIT
Latest version published 6 years ago

Package Health Score

74 / 100
Full package analysis