Small fixes for service requiring and warnings.
This commit is contained in:
parent
339f56157f
commit
a0d9aaedb8
@ -4,6 +4,7 @@ var path = require('path');
|
|||||||
var BitcoreNode = require('../node');
|
var BitcoreNode = require('../node');
|
||||||
var index = require('../');
|
var index = require('../');
|
||||||
var bitcore = require('bitcore-lib');
|
var bitcore = require('bitcore-lib');
|
||||||
|
var fs = require('fs');
|
||||||
var _ = bitcore.deps._;
|
var _ = bitcore.deps._;
|
||||||
var log = index.log;
|
var log = index.log;
|
||||||
var shuttingDown = false;
|
var shuttingDown = false;
|
||||||
@ -135,17 +136,22 @@ function checkService(service) {
|
|||||||
function loadModule(req, service) {
|
function loadModule(req, service) {
|
||||||
try {
|
try {
|
||||||
// first try in the built-in bitcore-node services directory
|
// first try in the built-in bitcore-node services directory
|
||||||
service.module = req(path.resolve(__dirname, '../services/' + service.name));
|
var serviceFile = path.resolve(__dirname, '../services/' + service.name);
|
||||||
} catch(e) {
|
if (fs.existsSync(serviceFile + '.js')) {
|
||||||
console.log(e);
|
// if the file exists, we can require it, then if there is a problem, catch and display the error
|
||||||
|
service.module = req(serviceFile);
|
||||||
// check if the package.json specifies a specific file to use
|
} else {
|
||||||
var servicePackage = req(service.name + '/package.json');
|
// check if the package.json specifies a specific file to use
|
||||||
var serviceModule = service.name;
|
var servicePackage = req(service.name + '/package.json');
|
||||||
if (servicePackage.bitcoreNode) {
|
var serviceModule = service.name;
|
||||||
serviceModule = service.name + '/' + servicePackage.bitcoreNode;
|
if (servicePackage.bitcoreNode) {
|
||||||
|
serviceModule = service.name + '/' + servicePackage.bitcoreNode;
|
||||||
|
}
|
||||||
|
service.module = req(serviceModule);
|
||||||
}
|
}
|
||||||
service.module = req(serviceModule);
|
} catch(e) {
|
||||||
|
log.error(e.stack);
|
||||||
|
process.exit(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -76,6 +76,7 @@ Bitcoin.DEFAULT_TRY_ALL_INTERVAL = 1000;
|
|||||||
Bitcoin.DEFAULT_REINDEX_INTERVAL = 10000;
|
Bitcoin.DEFAULT_REINDEX_INTERVAL = 10000;
|
||||||
Bitcoin.DEFAULT_START_RETRY_INTERVAL = 5000;
|
Bitcoin.DEFAULT_START_RETRY_INTERVAL = 5000;
|
||||||
Bitcoin.DEFAULT_TIP_UPDATE_INTERVAL = 15000;
|
Bitcoin.DEFAULT_TIP_UPDATE_INTERVAL = 15000;
|
||||||
|
Bitcoin.DEFAULT_ZMQ_DELAY_WARNING_MULTIPLIER = 5;
|
||||||
Bitcoin.DEFAULT_TRANSACTION_CONCURRENCY = 5;
|
Bitcoin.DEFAULT_TRANSACTION_CONCURRENCY = 5;
|
||||||
Bitcoin.DEFAULT_CONFIG_SETTINGS = {
|
Bitcoin.DEFAULT_CONFIG_SETTINGS = {
|
||||||
server: 1,
|
server: 1,
|
||||||
@ -114,6 +115,10 @@ Bitcoin.prototype._initDefaults = function(options) {
|
|||||||
|
|
||||||
// sync progress level when zmq subscribes to events
|
// sync progress level when zmq subscribes to events
|
||||||
this.zmqSubscribeProgress = options.zmqSubscribeProgress || Bitcoin.DEFAULT_ZMQ_SUBSCRIBE_PROGRESS;
|
this.zmqSubscribeProgress = options.zmqSubscribeProgress || Bitcoin.DEFAULT_ZMQ_SUBSCRIBE_PROGRESS;
|
||||||
|
|
||||||
|
// set the zmq delay warning multiplier
|
||||||
|
this.zmqDelayWarningMultiplier = options.zmqDelayWarningMultiplier || Bitcoin.DEFAULT_ZMQ_DELAY_WARNING_MULTIPLIER;
|
||||||
|
this.zmqDelayWarningMultiplierCouunt = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
Bitcoin.prototype._initCaches = function() {
|
Bitcoin.prototype._initCaches = function() {
|
||||||
@ -726,7 +731,10 @@ Bitcoin.prototype._initZmqSubSocket = function(node, zmqUrl) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
node.zmqSubSocket.on('connect_delay', function(fd, endPoint) {
|
node.zmqSubSocket.on('connect_delay', function(fd, endPoint) {
|
||||||
log.warn('ZMQ connection delay:', endPoint);
|
if (this.zmqDelayWarningMultiplierCouunt++ >= this.zmqDelayWarningMultiplier) {
|
||||||
|
log.warn('ZMQ connection delay:', endPoint);
|
||||||
|
this.zmqDelayWarningMultiplierCouunt = 0;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
node.zmqSubSocket.on('disconnect', function(fd, endPoint) {
|
node.zmqSubSocket.on('disconnect', function(fd, endPoint) {
|
||||||
@ -740,7 +748,8 @@ Bitcoin.prototype._initZmqSubSocket = function(node, zmqUrl) {
|
|||||||
}, 5000);
|
}, 5000);
|
||||||
});
|
});
|
||||||
|
|
||||||
node.zmqSubSocket.monitor(500, 0);
|
//monitors are polling and not event-driven
|
||||||
|
node.zmqSubSocket.monitor(100, 0);
|
||||||
node.zmqSubSocket.connect(zmqUrl);
|
node.zmqSubSocket.connect(zmqUrl);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -55,6 +55,7 @@
|
|||||||
"leveldown": "bitpay/leveldown#bitpay-1.4.4",
|
"leveldown": "bitpay/leveldown#bitpay-1.4.4",
|
||||||
"levelup": "^1.3.1",
|
"levelup": "^1.3.1",
|
||||||
"liftoff": "^2.2.0",
|
"liftoff": "^2.2.0",
|
||||||
|
"lmdb": "rvagg/lmdb#5ad819f77714925248dfecb0ba2174080dba949f",
|
||||||
"lru-cache": "^4.0.1",
|
"lru-cache": "^4.0.1",
|
||||||
"memdown": "^1.0.0",
|
"memdown": "^1.0.0",
|
||||||
"mkdirp": "0.5.0",
|
"mkdirp": "0.5.0",
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user