Skip to content

Commit

Permalink
Make --restart-tries restart forever with negative value
Browse files Browse the repository at this point in the history
Closes #263
  • Loading branch information
gustavohenke committed May 9, 2021
1 parent aad79fa commit e8f0706
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
5 changes: 3 additions & 2 deletions README.md
Expand Up @@ -169,9 +169,10 @@ Killing other processes
code [boolean]
Restarting
--restart-tries How many times a process that died should restart.
--restart-tries How many times a process that died should restart.
Negative numbers will make the process restart forever.
[number] [default: 0]
--restart-after Delay time to respawn the process, in milliseconds.
--restart-after Delay time to respawn the process, in milliseconds.
[number] [default: 0]
Options:
Expand Down
4 changes: 3 additions & 1 deletion bin/concurrently.js
Expand Up @@ -107,7 +107,9 @@ const args = yargs

// Restarting
'restart-tries': {
describe: 'How many times a process that died should restart.',
describe:
'How many times a process that died should restart.\n' +
'Negative numbers will make the process restart forever.',
default: defaults.restartTries,
type: 'number'
},
Expand Down
1 change: 1 addition & 0 deletions src/flow-control/restart-process.js
Expand Up @@ -7,6 +7,7 @@ module.exports = class RestartProcess {
constructor({ delay, tries, logger, scheduler }) {
this.delay = +delay || defaults.restartDelay;
this.tries = +tries || defaults.restartTries;
this.tries = this.tries < 0 ? Infinity : this.tries;
this.logger = logger;
this.scheduler = scheduler;
}
Expand Down
2 changes: 2 additions & 0 deletions src/flow-control/restart-process.spec.js
Expand Up @@ -69,6 +69,8 @@ it('restarts processes up to tries', () => {
expect(commands[0].start).toHaveBeenCalledTimes(2);
});

it.todo('restart processes forever, if tries is negative');

it('restarts processes until they succeed', () => {
controller.handle(commands);

Expand Down

0 comments on commit e8f0706

Please sign in to comment.