Adding retries to get the execution context.

This commit is contained in:
Matias committed 2019-04-30 11:25:30 -03:00
1 parent da30655808
commit 30eb354d45
4 files changed
+18 -6

No files matched your search

+2 -1
View File
@@ -299,7 +299,8 @@ exports.newAzureBlobBlobStorage = function newAzureBlobBlobStorage(BOT, logger)
err.code === 'EAI_AGAIN' ||
err.code === 'AuthenticationFailed' ||
err.code === 'OperationTimedOut' ||
err.code === 'ServerBusy'
err.code === 'ServerBusy' ||
text === undefined
) {
setTimeout(secondTry, SECOND_TRY_WAIT_TIME);
+14 -3
View File
@@ -238,6 +238,8 @@
if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write(MODULE_NAME, "[INFO] initialize -> getExecutionContext -> Entering function."); }
let date;
let maxRetries = 10;
let currentRetry = 0;
date = new Date(thisObject.statusReport.runs[runIndex].lastExecution);
thisObject.statusReport.runs[runIndex].lastExecution = bot.processDatetime;
@@ -264,6 +266,15 @@
logger.write(MODULE_NAME, "[INFO] initialize -> getExecutionContext -> onFileReceived -> Content received = " + text);
}
if(text === undefined){ // The File Sistem might be processing the request and delays can occur, in that case we will retry.
if(currentRetry < maxRetries){
logger.write(MODULE_NAME, "[WARN] initialize -> getExecutionContext -> onFileReceived -> retry to get the context from storage " + currentRetry);
currentRetry++;
cloudStorage.getTextFile(filePath, fileName, onFileReceived);
return;
}
}
try {
thisObject.executionContext = JSON.parse(text);
@@ -284,14 +295,14 @@
/*
It might happen that the file content is corrupt or it does not exist. The bot can not run without a Status Report,
since it is risky to ignore its own execution history. Execpt when the bot is running for the fist time in this mode,
since it is risky to ignore its own execution history. Except when the bot is running for the fist time in this mode,
an execution context file with the right format is needed.
*/
logger.write(MODULE_NAME, "[ERROR] initialize -> getExecutionContext -> onFileReceived -> Response from storage. -> Text = " + text);
logger.write(MODULE_NAME, "[ERROR] initialize -> getExecutionContext -> onFileReceived -> Response from storage. -> Text = " + text + ". Retry: "+currentRetry);
logger.write(MODULE_NAME, "[ERROR] initialize -> getExecutionContext -> onFileReceived -> Bot cannot execute without the Execution Context. -> Err = " + err.message);
callBack(global.DEFAULT_RETRY_RESPONSE);
callBack(global.DEFAULT_FAIL_RESPONSE);
}
}
+1 -1
View File
@@ -1,7 +1,7 @@
version: '3'
services:
node:
image: superalgos/clone-executor:1.0.3
image: superalgos/clone-executor:1.0.4
build:
context: .
dockerfile: ./Dockerfile
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@superalgos/clone-executor",
"version": "1.0.0",
"version": "1.0.4",
"description": "",
"main": "Run.js",
"scripts": {