Not resurrecting Delayed Loops
This commit is contained in:
1 parent
03a4029f8a
commit
1db7bb31f0
3 files changed
+48
-21
No files matched your search
@@ -155,6 +155,7 @@
|
||||
logger.initialize();
|
||||
|
||||
bot.loopCounter++;
|
||||
bot.loopStartTime = new Date().valueOf();
|
||||
|
||||
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] run -> loop -> Entering function."); }
|
||||
|
||||
@@ -475,16 +476,24 @@
|
||||
|
||||
function checkLoopHealth(pLastLoop) {
|
||||
|
||||
if (bot.loopCounter === pLastLoop + 1) { // This means that the next loop started but also stopped executing abruptally.
|
||||
if (bot.loopCounter <= pLastLoop + 1) { // This means that the next loop started but also stopped executing abruptally.
|
||||
|
||||
logger.write(MODULE_NAME, "[ERROR] run -> loop -> checkLoopHealth -> Dying loop found.");
|
||||
logger.write(MODULE_NAME, "[ERROR] run -> loop -> checkLoopHealth -> pLastLoop = " + pLastLoop);
|
||||
console.log((new Date().toISOString() + " " + bot.codeName + " " + bot.process + " Loop # " + Number(bot.loopCounter) + " found dead. Resurrecting it now."));
|
||||
let now = new Date().valueOf();
|
||||
|
||||
logger.persist(); // We persist the logs of the failed execution.
|
||||
clearTimeout(timeoutHandle); // We cancel the timeout in case the original loop was still running and schedulled to reexecute.
|
||||
loop(); // We restart the loop so that the processing can continue.
|
||||
if (now - bot.loopStartTime > processConfig.normalWaitTime) {
|
||||
|
||||
logger.write(MODULE_NAME, "[ERROR] run -> loop -> checkLoopHealth -> Dead loop found -> pLastLoop = " + pLastLoop);
|
||||
console.log((new Date().toISOString() + " [ERROR] run -> loop -> checkLoopHealth -> " + bot.codeName + " " + bot.process + " Loop # " + Number(bot.loopCounter) + " found dead. Resurrecting it now."));
|
||||
|
||||
logger.persist(); // We persist the logs of the failed execution.
|
||||
clearTimeout(timeoutHandle); // We cancel the timeout in case the original loop was still running and schedulled to reexecute.
|
||||
loop(); // We restart the loop so that the processing can continue.
|
||||
|
||||
} else {
|
||||
|
||||
console.log((new Date().toISOString() + " [WARN] run -> loop -> checkLoopHealth -> " + bot.codeName + " " + bot.process + " Loop # " + Number(bot.loopCounter) + " found delayed but still alive. No action taken."));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user