diff --git a/lib/consul/index.js b/lib/consul/index.js index b1fbdad..f1a824e 100644 --- a/lib/consul/index.js +++ b/lib/consul/index.js @@ -410,8 +410,16 @@ var process_records = function(branch, records, cb) { exports.getLastProcessedRef = function(branch, cb) { var key_name = create_key_name(branch, branch.name + '.ref', true); consul.kv.get({'key': key_name, token: token}, function(err, item) { - /* istanbul ignore if */ - if (err) return cb(err); + if(err) { + logger.warn('Cannot connect to consul to get the last processed reference id. Retrying!...'); + setTimeout( + function() { + exports.getLastProcessedRef(branch,cb); + },5000 + ); + // end this "thread" + return; + } cb(null, item === undefined ? item : item.Value); }); };