diff --git a/ExtractionBotProcessMainLoop.js b/ExtractionBotProcessMainLoop.js index b3701c186..7917a1dd7 100644 --- a/ExtractionBotProcessMainLoop.js +++ b/ExtractionBotProcessMainLoop.js @@ -461,10 +461,12 @@ case 'Normal': { if (bot.runAtFixedInterval === true) { if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] run -> loop -> loopControl -> Fixed Interval Normal exit point reached."); } + setTimeout(checkLoopHealth, bot.fixedInterval * 5, bot.loopCounter); logger.persist(); return; } else { if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] run -> loop -> loopControl -> Restarting Loop in " + (processConfig.normalWaitTime / 1000) + " seconds."); } + setTimeout(checkLoopHealth, processConfig.normalWaitTime * 5, bot.loopCounter); setTimeout(loop, processConfig.normalWaitTime); logger.persist(); } @@ -472,6 +474,7 @@ break; case 'Retry': { if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] run -> loop -> loopControl -> Restarting Loop in " + (processConfig.retryWaitTime / 1000) + " seconds."); } + setTimeout(checkLoopHealth, processConfig.retryWaitTime * 5, bot.loopCounter); setTimeout(loop, processConfig.retryWaitTime); logger.persist(); } @@ -504,6 +507,15 @@ } } + function checkLoopHealth(pLastLoop) { + + if (bot.loopCounter === pLastLoop + 1) { // This means that the next loop started but also stopped executing abruptally. + + logger.persist(); // We persist the logs of the failed execution. + loop(); // We restart the loop so that the processing can continue. + } + } + function shallWeStop(stopCallBack, continueCallBack) { try { diff --git a/IndicatorBotProcessMainLoop.js b/IndicatorBotProcessMainLoop.js index 4a09a2b11..cfc3776ba 100644 --- a/IndicatorBotProcessMainLoop.js +++ b/IndicatorBotProcessMainLoop.js @@ -442,12 +442,14 @@ switch (nextWaitTime) { case 'Normal': { if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] run -> loop -> loopControl -> Restarting Loop in " + (processConfig.normalWaitTime / 1000) + " seconds."); } + setTimeout(checkLoopHealth, processConfig.normalWaitTime * 5, bot.loopCounter); setTimeout(loop, processConfig.normalWaitTime); logger.persist(); } break; case 'Retry': { if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] run -> loop -> loopControl -> Restarting Loop in " + (processConfig.retryWaitTime / 1000) + " seconds."); } + setTimeout(checkLoopHealth, processConfig.retryWaitTime * 5, bot.loopCounter); setTimeout(loop, processConfig.retryWaitTime); logger.persist(); } @@ -468,6 +470,15 @@ } } + function checkLoopHealth(pLastLoop) { + + if (bot.loopCounter === pLastLoop + 1) { // This means that the next loop started but also stopped executing abruptally. + + logger.persist(); // We persist the logs of the failed execution. + loop(); // We restart the loop so that the processing can continue. + } + } + function shallWeStop(stopCallBack, continueCallBack) { try { diff --git a/TradingBotProcessMainLoop.js b/TradingBotProcessMainLoop.js index 1aea3d347..10d703a50 100644 --- a/TradingBotProcessMainLoop.js +++ b/TradingBotProcessMainLoop.js @@ -833,12 +833,14 @@ switch (nextWaitTime) { case 'Normal': { if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] run -> loop -> loopControl -> Normal -> Restarting Loop in " + (processConfig.normalWaitTime / 1000) + " seconds."); } + setTimeout(checkLoopHealth, processConfig.normalWaitTime * 5, bot.loopCounter); setTimeout(loop, processConfig.normalWaitTime); logger.persist(); } break; case 'Retry': { if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] run -> loop -> loopControl -> Retry -> Restarting Loop in " + (processConfig.retryWaitTime / 1000) + " seconds."); } + setTimeout(checkLoopHealth, processConfig.retryWaitTime * 5, bot.loopCounter); setTimeout(loop, processConfig.retryWaitTime); logger.persist(); } @@ -859,6 +861,15 @@ } } + function checkLoopHealth(pLastLoop) { + + if (bot.loopCounter === pLastLoop + 1) { // This means that the next loop started but also stopped executing abruptally. + + logger.persist(); // We persist the logs of the failed execution. + loop(); // We restart the loop so that the processing can continue. + } + } + function shallWeStop(stopCallBack, continueCallBack) { try {