diff --git a/lib/scaffold/start.js b/lib/scaffold/start.js index e1a4acf9..c4a2d981 100644 --- a/lib/scaffold/start.js +++ b/lib/scaffold/start.js @@ -4,6 +4,7 @@ var path = require('path'); var BitcoreNode = require('../node'); var index = require('../'); var bitcore = require('bitcore-lib'); +var fs = require('fs'); var _ = bitcore.deps._; var log = index.log; var shuttingDown = false; @@ -135,17 +136,22 @@ function checkService(service) { function loadModule(req, service) { try { // first try in the built-in bitcore-node services directory - service.module = req(path.resolve(__dirname, '../services/' + service.name)); - } catch(e) { - console.log(e); - - // check if the package.json specifies a specific file to use - var servicePackage = req(service.name + '/package.json'); - var serviceModule = service.name; - if (servicePackage.bitcoreNode) { - serviceModule = service.name + '/' + servicePackage.bitcoreNode; + var serviceFile = path.resolve(__dirname, '../services/' + service.name); + if (fs.existsSync(serviceFile + '.js')) { + // if the file exists, we can require it, then if there is a problem, catch and display the error + service.module = req(serviceFile); + } else { + // check if the package.json specifies a specific file to use + var servicePackage = req(service.name + '/package.json'); + var serviceModule = service.name; + 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); } } diff --git a/lib/services/bitcoind.js b/lib/services/bitcoind.js index f505d736..18fdf846 100644 --- a/lib/services/bitcoind.js +++ b/lib/services/bitcoind.js @@ -76,6 +76,7 @@ Bitcoin.DEFAULT_TRY_ALL_INTERVAL = 1000; Bitcoin.DEFAULT_REINDEX_INTERVAL = 10000; Bitcoin.DEFAULT_START_RETRY_INTERVAL = 5000; Bitcoin.DEFAULT_TIP_UPDATE_INTERVAL = 15000; +Bitcoin.DEFAULT_ZMQ_DELAY_WARNING_MULTIPLIER = 5; Bitcoin.DEFAULT_TRANSACTION_CONCURRENCY = 5; Bitcoin.DEFAULT_CONFIG_SETTINGS = { server: 1, @@ -114,6 +115,10 @@ Bitcoin.prototype._initDefaults = function(options) { // sync progress level when zmq subscribes to events 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() { @@ -726,7 +731,10 @@ Bitcoin.prototype._initZmqSubSocket = function(node, zmqUrl) { }); 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) { @@ -740,7 +748,8 @@ Bitcoin.prototype._initZmqSubSocket = function(node, zmqUrl) { }, 5000); }); - node.zmqSubSocket.monitor(500, 0); + //monitors are polling and not event-driven + node.zmqSubSocket.monitor(100, 0); node.zmqSubSocket.connect(zmqUrl); }; diff --git a/package.json b/package.json index c671afdb..268ce45c 100644 --- a/package.json +++ b/package.json @@ -55,6 +55,7 @@ "leveldown": "bitpay/leveldown#bitpay-1.4.4", "levelup": "^1.3.1", "liftoff": "^2.2.0", + "lmdb": "rvagg/lmdb#5ad819f77714925248dfecb0ba2174080dba949f", "lru-cache": "^4.0.1", "memdown": "^1.0.0", "mkdirp": "0.5.0",