Last change
on this file since 76712b2 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
840 bytes
|
Line | |
---|
1 | const log = require('../logger').create('launcher')
|
---|
2 |
|
---|
3 | function RetryLauncher (retryLimit) {
|
---|
4 | this._retryLimit = retryLimit
|
---|
5 |
|
---|
6 | this.on('done', () => {
|
---|
7 | if (!this.error) {
|
---|
8 | return
|
---|
9 | }
|
---|
10 |
|
---|
11 | if (this._retryLimit > 0) {
|
---|
12 | log.info(`Trying to start ${this.name} again (${retryLimit - this._retryLimit + 1}/${retryLimit}).`)
|
---|
13 | this.restart()
|
---|
14 | this._retryLimit--
|
---|
15 | } else if (this._retryLimit === 0) {
|
---|
16 | log.error(`${this.name} failed ${retryLimit} times (${this.error}). Giving up.`)
|
---|
17 | } else {
|
---|
18 | log.debug(`${this.name} failed (${this.error}). Not restarting.`)
|
---|
19 | }
|
---|
20 | })
|
---|
21 | }
|
---|
22 |
|
---|
23 | RetryLauncher.decoratorFactory = function (retryLimit) {
|
---|
24 | return function (launcher) {
|
---|
25 | RetryLauncher.call(launcher, retryLimit)
|
---|
26 | }
|
---|
27 | }
|
---|
28 |
|
---|
29 | RetryLauncher.decoratorFactory.$inject = ['config.retryLimit']
|
---|
30 |
|
---|
31 | module.exports = RetryLauncher
|
---|
Note:
See
TracBrowser
for help on using the repository browser.