1.0.19 • Published 6 years ago
worker_utils v1.0.19
#Worker Utils
Starts workers with a set priority (to run background tasks or to respond in high urgency), with keepAlive option to restart failing processes. ##Installation
npm install worker_utils --save
##Usage
const
os = require('os'),
WorkerUtils = require('./worker_utils.js');
var workerUtils = new WorkerUtils("Background Worker");
workerUtils.setVerbose(true);
workerUtils.run('./script_that_does_a_very_long_job.js', {
verbose : true,
priority : 10,// (below normal); ommit it and you will get normal
//flags : '-c', //put here the flags you want passed to node
argv : 'this_string_is_going_to_be_passed_as_an_argument', // the arguments string for you the child process
keepAlive : true // if the process craches, should we restart it?
//_restartLimit : 3, // this is the default restart limit (how many times)
//_restartDelay : 50 // this is the default restart delay (how much delay between each time)
}, function(proc, restarts){
if(proc){
console.log('proccess started ' + proc.pid + ' with a restart of ' + restarts);
}else{
console.log('proccess creation failed');
}
});
Notes
Windows
If you wish to use custom priority on a script, you might need write access on the running dir as wmic calls sometimes write a temp batch file
Nix
Uses nice for priority handling
1.0.19
6 years ago
1.0.18
6 years ago
1.0.17
6 years ago
1.0.16
6 years ago
1.0.15
6 years ago
1.0.14
6 years ago
1.0.13
6 years ago
1.0.12
6 years ago
1.0.11
6 years ago
1.0.10
6 years ago
1.0.9
6 years ago
1.0.8
6 years ago
1.0.7
6 years ago
1.0.6
6 years ago
1.0.5
6 years ago
1.0.4
6 years ago
1.0.3
6 years ago
1.0.2
6 years ago
1.0.1
6 years ago
1.0.0
6 years ago