Skip to content

Commit 18ba1a3

Browse files
committed
fix retry logic
1 parent b9ea11a commit 18ba1a3

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

.circleci/retry-orca-build-verify.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,24 @@ var spawn = require('child_process').spawn;
44

55
function retry(cmd, args, trials) {
66
if(trials === 0) {process.exit(1)}
7-
8-
console.log(trials + ' trials left');
9-
7+
var timer
108
function retryAfterTimeout() {
9+
console.log(trials + ' trials left');
1110
console.log('Retrying after no output for ' + timeout + ' seconds');
1211
child.kill();
1312
retry(cmd,args, --trials)
1413
}
1514

15+
function setTimer() {
16+
timer = setTimeout(retryAfterTimeout, timeout * 1000)
17+
}
18+
1619
const child = spawn(cmd,args);
20+
setTimer();
1721

18-
setTimeout(retryAfterTimeout, timeout * 1000)
1922
child.stdout.on('data', function(data) {
20-
clearTimeout(retryAfterTimeout);
23+
clearTimeout(timer);
24+
setTimer()
2125
console.log(data.toString());
2226
})
2327

@@ -27,7 +31,7 @@ function retry(cmd, args, trials) {
2731
})
2832

2933
child.on('close', function(code) {
30-
console.log('Excit with code ' + code);
34+
console.log('Exit with code ' + code);
3135
process.exit(code)
3236
})
3337
}

0 commit comments

Comments
 (0)