updated npm modules

This commit is contained in:
2019-05-20 20:43:45 -05:00
parent 2319197b81
commit f166b72b7d
1113 changed files with 8758 additions and 12227 deletions
+6 -2
View File
@@ -29,7 +29,7 @@ function handle (data) {
_args[0][key] = e[key]
})
}
process.send({ idx: idx, child: child, args: _args })
process.send({ owner: 'farm', idx: idx, child: child, args: _args })
}
, exec
@@ -46,7 +46,11 @@ function handle (data) {
process.on('message', function (data) {
if (data.owner !== 'farm') {
return;
}
if (!$module) return $module = require(data.module)
if (data == 'die') return process.exit(0)
if (data.event == 'die') return process.exit(0)
handle(data)
})
+14 -5
View File
@@ -10,6 +10,7 @@ const DEFAULT_OPTIONS = {
, maxRetries : Infinity
, forcedKillTime : 100
, autoStart : false
, onChild : function() {}
}
const fork = require('./fork')
@@ -29,8 +30,8 @@ function Farm (options, path) {
Farm.prototype.mkhandle = function (method) {
return function () {
let args = Array.prototype.slice.call(arguments)
if (this.activeCalls >= this.options.maxConcurrentCalls) {
let err = new MaxConcurrentCallsError('Too many concurrent calls (' + this.activeCalls + ')')
if (this.activeCalls + this.callQueue.length >= this.options.maxConcurrentCalls) {
let err = new MaxConcurrentCallsError('Too many concurrent calls (active: ' + this.activeCalls + ', queued: ' + this.callQueue.length + ')')
if (typeof args[args.length - 1] == 'function')
return process.nextTick(args[args.length - 1].bind(null, err))
throw err
@@ -113,7 +114,14 @@ Farm.prototype.startChild = function () {
, exitCode : null
}
forked.child.on('message', this.receive.bind(this))
this.options.onChild(forked.child);
forked.child.on('message', function(data) {
if (data.owner !== 'farm') {
return;
}
this.receive(data);
}.bind(this))
forked.child.once('exit', function (code) {
c.exitCode = code
this.onExit(id)
@@ -128,7 +136,7 @@ Farm.prototype.startChild = function () {
Farm.prototype.stopChild = function (childId) {
let child = this.children[childId]
if (child) {
child.send('die')
child.send({owner: 'farm', event: 'die'})
setTimeout(function () {
if (child.exitCode === null)
child.child.kill('SIGKILL')
@@ -234,7 +242,8 @@ Farm.prototype.send = function (childId, call) {
this.activeCalls++
child.send({
idx : idx
owner : 'farm'
, idx : idx
, child : childId
, method : call.method
, args : call.args
+1 -1
View File
@@ -20,7 +20,7 @@ function fork (forkModule, workerOptions) {
// this *should* be picked up by onExit and the operation requeued
})
child.send({ module: forkModule })
child.send({ owner: 'farm', module: forkModule })
// return a send() function for this child
return {
+1 -1
View File
@@ -26,7 +26,7 @@ function end (api, callback) {
for (let i = 0; i < farms.length; i++)
if (farms[i] && farms[i].api === api)
return farms[i].farm.end(callback)
process.nextTick(callback.bind(null, 'Worker farm not found!'))
process.nextTick(callback.bind(null, new Error('Worker farm not found!')))
}