Make update-slave-firmware.js extremely resilient (not a single failure out of 100 updates). Add shared.js
This commit is contained in:
24
scripts/shared.js
Normal file
24
scripts/shared.js
Normal file
@@ -0,0 +1,24 @@
|
||||
require('shelljs/global');
|
||||
|
||||
function execRetry(command) {
|
||||
let firstRun = true;
|
||||
let remainingRetries = 3;
|
||||
let code;
|
||||
do {
|
||||
if (!firstRun) {
|
||||
console.log(`Retrying ${command}`)
|
||||
}
|
||||
config.fatal = !remainingRetries;
|
||||
code = exec(command).code;
|
||||
config.fatal = true;
|
||||
firstRun = false;
|
||||
} while(code && --remainingRetries);
|
||||
}
|
||||
|
||||
const exp = {
|
||||
execRetry
|
||||
}
|
||||
|
||||
Object.keys(exp).forEach(function (cmd) {
|
||||
global[cmd] = exp[cmd];
|
||||
});
|
||||
Reference in New Issue
Block a user