Superalgos node v1

This commit is contained in:
Matias committed 2019-06-22 19:25:26 -03:00
1 parent 202265009d
commit 60f54bf994
10 files changed
+34 -47

No files matched your search

+2 -3
View File
@@ -11,6 +11,7 @@
const MULTI_PERIOD_MARKET = require(ROOT_DIR + 'MultiPeriodMarket');
const MULTI_PERIOD_DAILY = require(ROOT_DIR + 'MultiPeriodDaily');
const FILE_STORAGE = require('./Integrations/FileStorage.js');
let fileStorage = FILE_STORAGE.newFileStorage();
const DEBUG_MODULE = require(ROOT_DIR + 'DebugLog');
let logger; // We need this here in order for the loopHealth function to work and be able to rescue the loop when it gets in trouble.
@@ -38,8 +39,6 @@
UI_COMMANDS = pUI_COMMANDS;
processConfig = pProcessConfig;
let fileStorage = FILE_STORAGE.newFileStorage();
let filePath;
if (global.RUN_AS_TEAM) {
@@ -339,7 +338,7 @@
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] run -> loop -> initializeUserBot -> Entering function."); }
usertBot = USER_BOT_MODULE.newUserBot(bot, logger, COMMONS_MODULE, UTILITIES);
usertBot = USER_BOT_MODULE.newUserBot(bot, logger, COMMONS_MODULE, UTILITIES, fileStorage);
usertBot.initialize(statusDependencies, pMonth, pYear, onInizialized);
+17 -29
View File
@@ -13,10 +13,10 @@ exports.newFileStorage = function newFileStorage() {
function getTextFile(container, filePath, callBackFunction) {
try {
if (INFO_LOG === true) { console.log('[INFO] getTextFile -> Entering function: ' + filePath) }
if (INFO_LOG === true) { console.log('[INFO] getTextFile -> Entering function: '+ container.toLowerCase() + '/' + filePath) }
axios({
url: process.env.HOST_URL + 'graphql',
url: process.env.GATEWAY_ENDPOINT_K8S,
method: 'post',
data: {
query: `
@@ -46,13 +46,16 @@ exports.newFileStorage = function newFileStorage() {
callBackFunction(global.DEFAULT_OK_RESPONSE, response)
else
callBackFunction(global.CUSTOM_FAIL_RESPONSE)
}).catch(error => {
if (ERROR_LOG === true) { console.log('newFileStorage: [ERROR] getTextFile -> Invalid JSON received. ') }
if (ERROR_LOG === true) { console.log('newFileStorage: [ERROR] getTextFile -> response.text = ' + error.message) }
if (ERROR_LOG === true) { console.log('newFileStorage: [ERROR] getTextFile -> error = ', error) }
callBackFunction(global.DEFAULT_FAIL_RESPONSE)
})
} catch (err) {
if (ERROR_LOG === true) { console.log('[ERROR] getTextFile -> err = ' + err.stack) }
if (ERROR_LOG === true) { console.log('[ERROR] getTextFile -> err = ', err) }
if (ERROR_LOG === true) { console.log('[ERROR] getTextFile -> stack = ', err.stack) }
callBackFunction(global.DEFAULT_FAIL_RESPONSE)
}
}
@@ -61,7 +64,7 @@ exports.newFileStorage = function newFileStorage() {
if (INFO_LOG === true) { console.log('[INFO] createTextFile -> Entering function: ' + filePath) }
let response = await axios({
url: process.env.HOST_URL + 'graphql',
url: process.env.GATEWAY_ENDPOINT_K8S,
method: 'post',
data: {
query: `
@@ -73,38 +76,23 @@ exports.newFileStorage = function newFileStorage() {
file: {
container: container.toLowerCase(),
filePath,
storage: process.env.HOST_STORAGE,
accessKey: process.env.HOST_ACCESS_KEY,
storage: 'localStorage',
accessKey: '', //TODO Pending
fileContent
}
}
}
})
if(!response){
console.log('[ERROR] createTextFile -> err = ')
}
if (!response || response.data.errors)
callBackFunction(global.CUSTOM_FAIL_RESPONSE)
else
callBackFunction(global.DEFAULT_OK_RESPONSE)
// .then(res => {
// if (res.data.errors) {
// let error = {
// code: res.data.errors[0]
// }
// callBackFunction(error)
// return
// }
// let response = res.data.data.web_CreateFile
// if (response)
// callBackFunction(global.DEFAULT_OK_RESPONSE)
// else
// callBackFunction(global.CUSTOM_FAIL_RESPONSE)
// }).catch(error => {
// if (ERROR_LOG === true) { console.log('newFileStorage: [ERROR] createTextFile -> Invalid JSON received. ') }
// if (ERROR_LOG === true) { console.log('newFileStorage: [ERROR] createTextFile -> response.text = ' + error.message) }
// callBackFunction(global.DEFAULT_FAIL_RESPONSE)
// })
} catch (err) {
if (ERROR_LOG === true) { console.log('[ERROR] createTextFile -> err = ' + err.stack) }
if (ERROR_LOG === true) { console.log('[ERROR] createTextFile -> err = ', err.stack) }
if (ERROR_LOG === true) { console.log('[ERROR] createTextFile -> stack = ', err.stack) }
callBackFunction(global.DEFAULT_FAIL_RESPONSE)
}
}
+2 -2
View File
@@ -15,7 +15,7 @@ exports.getStrategy = async function () {
}
const strategizerResponse = await axios({
url: process.env.STRATEGIZER_ENDPOINT || process.env.GATEWAY_ENDPOINT,
url: process.env.STRATEGIZER_ENDPOINT || process.env.GATEWAY_ENDPOINT_K8S,
method: 'post',
data: {
query: `
@@ -42,6 +42,6 @@ exports.getStrategy = async function () {
return global.STRATEGY
} catch (error) {
throw new Error('There has been an error getting the strategy: ' + error)
throw new Error('There has been an error getting the strategy: ', error)
}
}
+4 -4
View File
@@ -58,7 +58,7 @@
}
usertBot = USER_BOT_MODULE.newUserBot(bot, logger, COMMONS_MODULE, UTILITIES);
usertBot = USER_BOT_MODULE.newUserBot(bot, logger, COMMONS_MODULE, UTILITIES, fileStorage);
usertBot.initialize(dataDependencies, callBackFunction);
} catch (err) {
@@ -421,7 +421,7 @@
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> processTimePeriods -> periodsLoopBody -> dependencyLoopBody -> getPreviousFile -> onFileReceived -> Entering function."); }
if (LOG_FILE_CONTENT === true) { logger.write(MODULE_NAME, "[INFO] start -> processTimePeriods -> periodsLoopBody -> dependencyLoopBody -> getPreviousFile -> onFileReceived -> text = " + text); }
if (err.message === "File does not exist." && botNeverRan === true) {
if ((err.message === "File does not exist." && botNeverRan === true) || err.code === 'The specified key does not exist.') {
/*
Sometimes one of the dependencies of an indicator for some reasons are not calculated from the begining of the market.
@@ -436,7 +436,7 @@
return;
}
if (err.result === "Fail Because" && err.message === "File does not exist.") {
if ((err.result === "Fail Because" && err.message === "File does not exist.") || err.code === 'The specified key does not exist.') {
logger.write(MODULE_NAME, "[ERROR] start -> processTimePeriods -> periodsLoopBody -> dependencyLoopBody -> getCurrentFile -> onFileReceived -> err = " + err.message);
logger.write(MODULE_NAME, "[ERROR] start -> processTimePeriods -> periodsLoopBody -> dependencyLoopBody -> getCurrentFile -> onFileReceived -> filePath = " + filePath);
@@ -490,7 +490,7 @@
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> processTimePeriods -> periodsLoopBody -> dependencyLoopBody -> getCurrentFile -> onFileReceived -> Entering function."); }
if (LOG_FILE_CONTENT === true) { logger.write(MODULE_NAME, "[INFO] start -> processTimePeriods -> periodsLoopBody -> dependencyLoopBody -> getCurrentFile -> onFileReceived -> text = " + text); }
if (err.result === "Fail Because" && err.message === "File does not exist.") {
if ((err.result === "Fail Because" && err.message === "File does not exist.") || err.code === 'The specified key does not exist.') {
logger.write(MODULE_NAME, "[ERROR] start -> processTimePeriods -> periodsLoopBody -> dependencyLoopBody -> getCurrentFile -> onFileReceived -> err = " + err.message);
logger.write(MODULE_NAME, "[ERROR] start -> processTimePeriods -> periodsLoopBody -> dependencyLoopBody -> getCurrentFile -> onFileReceived -> filePath = " + filePath);
+4 -1
View File
@@ -16,6 +16,9 @@
let usertBot;
const FILE_STORAGE = require('./Integrations/FileStorage.js');
let fileStorage = FILE_STORAGE.newFileStorage();
let processConfig;
return thisObject;
@@ -51,7 +54,7 @@
}
usertBot = USER_BOT_MODULE.newUserBot(bot, logger, COMMONS_MODULE, UTILITIES);
usertBot = USER_BOT_MODULE.newUserBot(bot, logger, COMMONS_MODULE, UTILITIES, fileStorage);
usertBot.initialize(dataDependencies, callBackFunction);
} catch (err) {
-3
View File
@@ -35,9 +35,6 @@ function readExecutionConfiguration() {
console.log("[INFO] Run -> readExecutionConfiguration -> Entering function. ");
let startMode
// Environment Configuration
global.GATEWAY_ENDPOINT = process.env.GATEWAY_ENDPOINT
// General Financial Being Configuration
global.DEV_TEAM = process.env.DEV_TEAM
global.CURRENT_BOT_REPO = process.env.BOT + "-" + process.env.TYPE + "-Bot"
+1 -1
View File
@@ -303,7 +303,7 @@
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] run -> loop -> initializeUserBot -> Entering function."); }
usertBot = USER_BOT_MODULE.newUserBot(bot, logger, COMMONS_MODULE, UTILITIES, STATUS_REPORT, exchangeAPI);
usertBot = USER_BOT_MODULE.newUserBot(bot, logger, COMMONS_MODULE, UTILITIES, fileStorage, STATUS_REPORT, exchangeAPI);
usertBot.initialize(statusDependencies, pMonth, pYear, onInizialized);
+2 -2
View File
@@ -91,7 +91,7 @@
filePath += '/' + fileName
fileStorage.getTextFile(global.DEV_TEAM, filePath, onFileReceived);
fileStorage.getTextFile(owner.devTeam, filePath, onFileReceived);
function onFileReceived(err, text) {
@@ -187,7 +187,7 @@
let fileContent = JSON.stringify(thisObject.file);
fileStorage.createTextFile(global.DEV_TEAM, filePath, fileContent + '\n', onFileCreated);
fileStorage.createTextFile(owner.devTeam, filePath, fileContent + '\n', onFileCreated);
function onFileCreated(err) {
+1 -1
View File
@@ -1,7 +1,7 @@
version: '3'
services:
node:
image: superalgos/clone-executor:1.0.12
image: superalgos/clone-executor:1.0.25
build:
context: .
dockerfile: ./Dockerfile
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@superalgos/clone-executor",
"version": "1.0.12",
"version": "1.0.25",
"description": "Module responsible for executing the bots on the cloud.",
"author": "Superalgos, ltd.",
"license": "Apache-2.0",