mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-19 17:14:57 +00:00
add 1 minute retry
This commit is contained in:
parent
d427e06136
commit
11688f5778
@ -1,6 +1,10 @@
|
||||
let alfrescoApi = require('@alfresco/js-api');
|
||||
let program = require('commander');
|
||||
|
||||
let MAX_RETRY = 10;
|
||||
let counter = 0;
|
||||
let TIMEOUT = 60000;
|
||||
|
||||
async function main() {
|
||||
|
||||
program
|
||||
@ -10,18 +14,36 @@ async function main() {
|
||||
.option('-u, --username [type]', 'username ')
|
||||
.parse(process.argv);
|
||||
|
||||
try {
|
||||
|
||||
await checkEnv();
|
||||
}
|
||||
|
||||
async function checkEnv() {
|
||||
try {
|
||||
this.alfrescoJsApi = new alfrescoApi.AlfrescoApiCompatibility({
|
||||
provider: 'BPM',
|
||||
hostEcm: program.host
|
||||
provider: 'ECM',
|
||||
hostEcm: program.host
|
||||
});
|
||||
|
||||
await this.alfrescoJsApi.login(program.username, program.password);
|
||||
} catch (e) {
|
||||
console.log('Login error environment down or inaccessible');
|
||||
process.exit(1);
|
||||
counter++;
|
||||
if (MAX_RETRY === counter) {
|
||||
console.log('Give up');
|
||||
process.exit(1);
|
||||
} else {
|
||||
console.log(`Retry in 1 minute attempt N ${counter}`);
|
||||
sleep(TIMEOUT);
|
||||
checkEnv();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function sleep(delay) {
|
||||
var start = new Date().getTime();
|
||||
while (new Date().getTime() < start + delay) ;
|
||||
}
|
||||
|
||||
main();
|
||||
|
@ -1,6 +1,10 @@
|
||||
let alfrescoApi = require('@alfresco/js-api');
|
||||
let program = require('commander');
|
||||
|
||||
let MAX_RETRY = 10;
|
||||
let counter = 0;
|
||||
let TIMEOUT = 60000;
|
||||
|
||||
async function main() {
|
||||
|
||||
program
|
||||
@ -10,18 +14,36 @@ async function main() {
|
||||
.option('-u, --username [type]', 'username ')
|
||||
.parse(process.argv);
|
||||
|
||||
try {
|
||||
|
||||
await checkEnv();
|
||||
}
|
||||
|
||||
async function checkEnv() {
|
||||
try {
|
||||
this.alfrescoJsApi = new alfrescoApi.AlfrescoApiCompatibility({
|
||||
provider: 'ECM',
|
||||
hostEcm: program.host
|
||||
provider: 'BPM',
|
||||
hostBpm: program.host
|
||||
});
|
||||
|
||||
await this.alfrescoJsApi.login(program.username, program.password);
|
||||
} catch (e) {
|
||||
console.log('Login error environment down or inaccessible');
|
||||
process.exit(1);
|
||||
counter++;
|
||||
if (MAX_RETRY === counter) {
|
||||
console.log('Give up');
|
||||
process.exit(1);
|
||||
} else {
|
||||
console.log(`Retry in 1 minute attempt N ${counter}`);
|
||||
sleep(TIMEOUT);
|
||||
checkEnv();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function sleep(delay) {
|
||||
var start = new Date().getTime();
|
||||
while (new Date().getTime() < start + delay) ;
|
||||
}
|
||||
|
||||
main();
|
||||
|
Loading…
x
Reference in New Issue
Block a user