Sha256: 217341909209a989425ff380458e16d667c3da98df660749f5ffe5e2ce2e8f96
Contents?: true
Size: 834 Bytes
Versions: 17
Compression:
Stored size: 834 Bytes
Contents
var log = require('../logger').create('launcher'); var RetryLauncher = function(retryLimit) { var self = this; this._retryLimit = retryLimit; this.on('done', function() { if (!self.error) { return; } if (self._retryLimit > 0) { var attempt = retryLimit - self._retryLimit + 1; log.info('Trying to start %s again (%d/%d).', self.name, attempt, retryLimit); self.restart(); self._retryLimit--; } else if (self._retryLimit === 0) { log.error('%s failed %d times (%s). Giving up.', self.name, retryLimit, self.error); } else { log.debug('%s failed (%s). Not restarting.', self.name, self.error); } }); }; RetryLauncher.decoratorFactory = function() { return function(launcher) { RetryLauncher.call(launcher, 2); }; }; module.exports = RetryLauncher;
Version data entries
17 entries across 17 versions & 2 rubygems