HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/buyercall/node_modules/karma/lib/launchers/retry.js
const log = require('../logger').create('launcher')

function RetryLauncher (retryLimit) {
  this._retryLimit = retryLimit

  this.on('done', () => {
    if (!this.error) {
      return
    }

    if (this._retryLimit > 0) {
      log.info(`Trying to start ${this.name} again (${retryLimit - this._retryLimit + 1}/${retryLimit}).`)
      this.restart()
      this._retryLimit--
    } else if (this._retryLimit === 0) {
      log.error(`${this.name} failed ${retryLimit} times (${this.error}). Giving up.`)
    } else {
      log.debug(`${this.name} failed (${this.error}). Not restarting.`)
    }
  })
}

RetryLauncher.decoratorFactory = function (retryLimit) {
  return function (launcher) {
    RetryLauncher.call(launcher, retryLimit)
  }
}

RetryLauncher.decoratorFactory.$inject = ['config.retryLimit']

module.exports = RetryLauncher