Azure File Storage Initialization debugged

This commit is contained in:
Luis Fernando Molina committed 2018-03-07 20:20:42 +01:00
1 parent 14367c1746
commit 0bbcc4588c
15 files changed
+63 -87

No files matched your search

Binary file not shown.
-7
View File
@@ -1,7 +0,0 @@
{
"useDevelopmentStorage": false,
"connectionString": "DefaultEndpointsProtocol=https;AccountName=aatestnet;AccountKey=rQRuD8KeD0upqcN9532zqZTknKwkYJDpGzkATGptk9lIEovkLchdOGOJVld26cUjpzTA4enxsxpCB33B0pOZRg==;EndpointSuffix=core.windows.net",
"accountName": "",
"accountKey": "",
"sas": ""
}
-7
View File
@@ -1,7 +0,0 @@
{
"useDevelopmentStorage": false,
"connectionString": "DefaultEndpointsProtocol=https;AccountName=aatestnet;AccountKey=rQRuD8KeD0upqcN9532zqZTknKwkYJDpGzkATGptk9lIEovkLchdOGOJVld26cUjpzTA4enxsxpCB33B0pOZRg==;EndpointSuffix=core.windows.net",
"accountName": "",
"accountKey": "",
"sas": ""
}
-7
View File
@@ -1,7 +0,0 @@
{
"useDevelopmentStorage": false,
"connectionString": "DefaultEndpointsProtocol=https;AccountName=aatestnet;AccountKey=rQRuD8KeD0upqcN9532zqZTknKwkYJDpGzkATGptk9lIEovkLchdOGOJVld26cUjpzTA4enxsxpCB33B0pOZRg==;EndpointSuffix=core.windows.net",
"accountName": "",
"accountKey": "",
"sas": ""
}
+1
View File
@@ -20,6 +20,7 @@
const logger = DEBUG_MODULE.newDebugLog();
logger.fileName = MODULE_NAME;
logger.bot = bot;
let exchangePositions = []; // These are the open positions at the exchange at the account the bot is authorized to use.
let openPositions = []; // These are the open positions the bot knows it made by itself.
+41 -19
View File
@@ -15,7 +15,7 @@ exports.newAzureFileStorage = function newAzureFileStorage(BOT) {
const DEBUG_MODULE = require('./Debug Log');
const logger = DEBUG_MODULE.newDebugLog();
logger.pFileName = MODULE_NAME;
logger.fileName = MODULE_NAME;
logger.bot = bot;
const shareName = 'data';
@@ -45,28 +45,50 @@ exports.newAzureFileStorage = function newAzureFileStorage(BOT) {
dataOwner = pDataOwnerBotCodeName;
}
fileService = storage.createFileService(readConfig().connectionString);
readConnectionStringConfigFile(onConnectionStringReady);
callBackFunction(global.DEFAULT_OK_RESPONSE);
function onConnectionStringReady(err, pConnObj) {
if (err.result !== global.DEFAULT_OK_RESPONSE.result) {
logger.write("[ERROR] initialize -> onConnectionStringReady -> err = " + err.message);
callBackFunction(err);
return;
}
try {
fileService = storage.createFileService(pConnObj.connectionString);
callBackFunction(global.DEFAULT_OK_RESPONSE);
} catch (err) {
logger.write("[ERROR] initialize -> onConnectionStringReady -> createFileService -> err = " + err.message);
callBackFunction(err);
return;
}
}
function readConnectionStringConfigFile(callBack) {
let filePath;
try {
let fs = require('fs');
filePath = '../' + 'Connection-Strings' + '/' + global.RUNNING_MODE + '/' + dataOwner + '.azure.storage.connstring';
let connObj = JSON.parse(fs.readFileSync(filePath, 'utf8'));
callBack(global.DEFAULT_OK_RESPONSE, connObj);
}
catch (err) {
logger.write("[ERROR] readConnectionStringConfigFile -> err = " + err.message);
logger.write("[HINT] readConnectionStringConfigFile -> You need to have a file at this path -> " + filePath);
logger.write("[HINT] readConnectionStringConfigFile -> The file must have the connection string to the Azure Storage Account. Request the file to an AA Team Member if you dont have it.");
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
}
}
}
catch (err) {
logger.write("[ERROR] initialize -> err = " + err.message);
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
}
}
function readConfig() {
try {
let fs = require('fs');
let filePath = '../' + 'Connection-Strings' + '/' + global.RUNNING_MODE + '/' + dataOwner + '.azure.storage.connstring' + '.json';
return JSON.parse(fs.readFileSync(filePath, 'utf8'));
}
catch (err) {
logger.write("[ERROR] readConfig -> err = " + err.message);
logger.write("[HINT] You need to have a file at this path -> " + filePath);
logger.write("[HINT] The file must have the connection string to the Azure Storage Account. Request the file to an AA Team Member if you dont have it.");
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
callBack(global.DEFAULT_FAIL_RESPONSE);
}
}
-7
View File
@@ -1,7 +0,0 @@
{
"useDevelopmentStorage": false,
"connectionString": "DefaultEndpointsProtocol=https;AccountName=aatestnet;AccountKey=rQRuD8KeD0upqcN9532zqZTknKwkYJDpGzkATGptk9lIEovkLchdOGOJVld26cUjpzTA4enxsxpCB33B0pOZRg==;EndpointSuffix=core.windows.net",
"accountName": "",
"accountKey": "",
"sas": ""
}
-7
View File
@@ -1,7 +0,0 @@
{
"useDevelopmentStorage": false,
"connectionString": "DefaultEndpointsProtocol=https;AccountName=aatestnet;AccountKey=rQRuD8KeD0upqcN9532zqZTknKwkYJDpGzkATGptk9lIEovkLchdOGOJVld26cUjpzTA4enxsxpCB33B0pOZRg==;EndpointSuffix=core.windows.net",
"accountName": "",
"accountKey": "",
"sas": ""
}
-7
View File
@@ -1,7 +0,0 @@
{
"useDevelopmentStorage": false,
"connectionString": "DefaultEndpointsProtocol=https;AccountName=aatestnet;AccountKey=rQRuD8KeD0upqcN9532zqZTknKwkYJDpGzkATGptk9lIEovkLchdOGOJVld26cUjpzTA4enxsxpCB33B0pOZRg==;EndpointSuffix=core.windows.net",
"accountName": "",
"accountKey": "",
"sas": ""
}
+1
View File
@@ -58,6 +58,7 @@
const logger = DEBUG_MODULE.newDebugLog();
logger.fileName = MODULE_NAME;
logger.bot = bot;
/* Storage account to be used here. */
+1 -1
View File
@@ -22,7 +22,7 @@
const logger = DEBUG_MODULE.newDebugLog();
logger.fileName = MODULE_NAME;
logger.bot = bot;
let marketFilesPeriods =
'[' +
+1
View File
@@ -22,6 +22,7 @@
const logger = DEBUG_MODULE.newDebugLog();
logger.fileName = MODULE_NAME;
logger.bot = bot;
let poloniexApiClient;
-7
View File
@@ -1,7 +0,0 @@
{
"useDevelopmentStorage": false,
"connectionString": "DefaultEndpointsProtocol=https;AccountName=aadata;AccountKey=YOu76OjlJX9T1QTWbj5cvqyYXTdufW1jISNyrtr8RlUK++kVIdm/TnYuyLJzp8kptAEhbQnN4PP3c6SoPLvR+A==;EndpointSuffix=core.windows.net",
"accountName": "",
"accountKey": "",
"sas": ""
}
+2 -2
View File
@@ -201,9 +201,9 @@ function runTradingBot(pProcessConfig) {
if (err.result === global.DEFAULT_OK_RESPONSE.result) {
tradingBot.start(whenStartFinishes);
tradingBot.run(whenRunFinishes);
function whenStartFinishes(err) {
function whenRunFinishes(err) {
if (err.result === global.DEFAULT_OK_RESPONSE.result) {
+16 -16
View File
@@ -15,7 +15,7 @@
thisObject = {
initialize: initialize,
start: start
run: run
};
let processConfig;
@@ -38,17 +38,17 @@
}
}
function start(callBackFunction) {
function run(callBackFunction) {
try {
if (FULL_LOG === true) { logger.write("[INFO] start -> Entering function."); }
if (FULL_LOG === true) { logger.write("[INFO] run -> Entering function."); }
loop();
function loop() {
try {
if (FULL_LOG === true) { logger.write("[INFO] start -> loop -> Entering function."); }
if (FULL_LOG === true) { logger.write("[INFO] run -> loop -> Entering function."); }
/* We define here all the modules that the rest of the infraestructure, including the bots themselves can consume. */
@@ -88,7 +88,7 @@
if (err.result === global.DEFAULT_OK_RESPONSE.result) {
initializeDatasource();
} else {
logger.write("[ERROR] start -> loop -> initializeContext -> err = " + err.message);
logger.write("[ERROR] run -> loop -> initializeContext -> err = " + err.message);
callBackFunction(err);
}
}
@@ -104,7 +104,7 @@
if (err.result === global.DEFAULT_OK_RESPONSE.result) {
initializeExchangeAPI();
} else {
logger.write("[ERROR] start -> loop -> initializeDatasource -> err = " + err.message);
logger.write("[ERROR] run -> loop -> initializeDatasource -> err = " + err.message);
callBackFunction(err);
}
}
@@ -120,7 +120,7 @@
if (err.result === global.DEFAULT_OK_RESPONSE.result) {
initializeAssistant();
} else {
logger.write("[ERROR] start -> loop -> initializeExchangeAPI -> err = " + err.message);
logger.write("[ERROR] run -> loop -> initializeExchangeAPI -> err = " + err.message);
callBackFunction(err);
}
}
@@ -136,7 +136,7 @@
if (err.result === global.DEFAULT_OK_RESPONSE.result) {
initializeUserBot();
} else {
logger.write("[ERROR] start -> loop -> initializeAssistant -> err = " + err.message);
logger.write("[ERROR] run -> loop -> initializeAssistant -> err = " + err.message);
callBackFunction(err);
}
}
@@ -160,7 +160,7 @@
if (err.result === global.DEFAULT_OK_RESPONSE.result) {
startUserBot();
} else {
logger.write("[ERROR] start -> loop -> initializeUserBot -> err = " + err.message);
logger.write("[ERROR] run -> loop -> initializeUserBot -> err = " + err.message);
callBackFunction(err);
}
}
@@ -168,7 +168,7 @@
function startUserBot() {
usertBot.start(platform, onFinished);
usertBot.run(platform, onFinished);
function onFinished(err) {
@@ -186,7 +186,7 @@
}
break;
case global.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle.
logger.write("[ERROR] start -> loop -> startUserBot -> Operation Failed. Aborting the process.");
logger.write("[ERROR] run -> loop -> startUserBot -> Operation Failed. Aborting the process.");
callBackFunction(err);
return;
}
@@ -204,14 +204,14 @@
if (err.result === global.DEFAULT_OK_RESPONSE.result) {
loopControl(nextWaitTime);
} else {
logger.write("[ERROR] start -> loop -> saveContext -> err = " + err.message);
logger.write("[ERROR] run -> loop -> saveContext -> err = " + err.message);
callBackFunction(err);
}
}
}
} catch (err) {
logger.write("[ERROR] start -> loop -> err = " + err.message);
logger.write("[ERROR] run -> loop -> err = " + err.message);
callBackFunction(err);
}
}
@@ -222,12 +222,12 @@
switch (nextWaitTime) {
case 'Normal': {
if (FULL_LOG === true) { logger.write("[INFO] start -> loopControl -> Restarting Loop in " + (processConfig.executionWaitTime / 1000) + " seconds."); }
if (FULL_LOG === true) { logger.write("[INFO] run -> loopControl -> Restarting Loop in " + (processConfig.executionWaitTime / 1000) + " seconds."); }
setTimeout(loop, processConfig.executionWaitTime);
}
break;
case 'Retry': {
if (FULL_LOG === true) { logger.write("[INFO] start -> loopControl -> Restarting Loop in " + (processConfig.retryWaitTime / 1000) + " seconds."); }
if (FULL_LOG === true) { logger.write("[INFO] run -> loopControl -> Restarting Loop in " + (processConfig.retryWaitTime / 1000) + " seconds."); }
setTimeout(loop, processConfig.retryWaitTime);
}
break;
@@ -236,7 +236,7 @@
}
catch (err) {
logger.write("[ERROR] start -> err = " + err.message);
logger.write("[ERROR] run -> err = " + err.message);
}
}
};