worker-manager
Have long running tasks that you want to perform without blocking your main process?
Use: worker-manager
The manager with handle all the scaryness of "threading" or using "forked processes".
Just created a worker file that has all your long runing tasks on it. The manager
will supply a woker object that will handle all thread communications, just use
"worker.on(taskName, taskFunction);" in your worker file to redgestor your tasks.
To use worker-manager:
npm install worker-manager
Documentation:
var manager = ; var man = manager workerFilename: Stringfile path to worker file workerLimit: Numbermaximun number of worker keepAlive: Booleankeep workers alive when not in uses properties: managerworkers: Numbernumber of worker manageractiveWorkers: Numbernumber of worker doing tasks managertasks: Numbernumber of unfinished tasks methods: manager arguments: taskName: Stringname given to task in worker file data: Argumentsarguments supplied to worker task callback: Functionwhat gets called when task is completed args: err data mess err: Errorif worker has error completing task data: Returnswhat the worker task returns mess: Objectfull details of task at hand returns: Numberid assigned to task by manager does: creates a and sends it to a worker to be done calls the callback give on task completetion managercleartaskId arguments: taskId: Numberid assigned to task by manager returns: Booleantrue if task was cleared false otherwise does: clears task if task hasn't being completed.
Example Worker file: 'worker.js'
var worker = ; worker; worker;
Example in app file:
var manager = ; var man = manager; man; man;
Created By:
Michaelangelo Jong