From e1bf2aab7f28b1f700780f73637e4f21666acf1a Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 8 Jun 2018 14:39:19 +0200 Subject: [PATCH] Improvement in health care --- ExtractionBotProcessMainLoop.js | 7 +++++++ IndicatorBotProcessMainLoop.js | 7 +++++++ TradingBotProcessMainLoop.js | 7 +++++++ 3 files changed, 21 insertions(+) diff --git a/ExtractionBotProcessMainLoop.js b/ExtractionBotProcessMainLoop.js index 7917a1dd7..7ba6999af 100644 --- a/ExtractionBotProcessMainLoop.js +++ b/ExtractionBotProcessMainLoop.js @@ -140,7 +140,9 @@ function loop() { try { + console.log((new Date().toISOString() + " " + bot.codeName + " " + bot.process + " Entered into Loop # " + (Number(bot.loopCounter) + 1))); + /* For each loop we want to create a new log file. */ const DEBUG_MODULE = require(ROOT_DIR + 'DebugLog'); @@ -511,8 +513,13 @@ 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.")); + logger.persist(); // We persist the logs of the failed execution. loop(); // We restart the loop so that the processing can continue. + } } diff --git a/IndicatorBotProcessMainLoop.js b/IndicatorBotProcessMainLoop.js index cfc3776ba..f68e7e1f5 100644 --- a/IndicatorBotProcessMainLoop.js +++ b/IndicatorBotProcessMainLoop.js @@ -141,7 +141,9 @@ function loop() { try { + console.log((new Date().toISOString() + " " + bot.codeName + " " + bot.process + " Entered into Loop # " + (Number(bot.loopCounter) + 1))); + /* For each loop we want to create a new log file. */ const DEBUG_MODULE = require(ROOT_DIR + 'DebugLog'); @@ -474,8 +476,13 @@ 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.")); + logger.persist(); // We persist the logs of the failed execution. loop(); // We restart the loop so that the processing can continue. + } } diff --git a/TradingBotProcessMainLoop.js b/TradingBotProcessMainLoop.js index 10d703a50..d63b65629 100644 --- a/TradingBotProcessMainLoop.js +++ b/TradingBotProcessMainLoop.js @@ -142,6 +142,8 @@ try { + console.log((new Date().toISOString() + " " + bot.codeName + " " + bot.process + " Entered into Loop # " + (Number(bot.loopCounter) + 1))); + /* For each loop we want to create a new log file. */ const DEBUG_MODULE = require(ROOT_DIR + 'DebugLog'); @@ -865,8 +867,13 @@ 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." )); + logger.persist(); // We persist the logs of the failed execution. loop(); // We restart the loop so that the processing can continue. + } }