Browse Source

Merge pull request #71 from pbca26/master

added iguana port override
all-modes
pbca26 8 years ago
committed by GitHub
parent
commit
59a085c225
  1. 1
      gui/index.html
  2. 4
      gui/init.js
  3. 11
      gui/loading.js
  4. 2
      main.js
  5. 9
      routes/cache.js
  6. 90
      routes/shepherd.js

1
gui/index.html

@ -7,6 +7,7 @@
<link rel="stylesheet" href="loading.css"> <link rel="stylesheet" href="loading.css">
<script type="text/javascript" src="module-hack.js"></script> <script type="text/javascript" src="module-hack.js"></script>
<script type="text/javascript" src="EasyDEX-GUI/assets/global/vendor/jquery/jquery.min.js"></script> <script type="text/javascript" src="EasyDEX-GUI/assets/global/vendor/jquery/jquery.min.js"></script>
<script type="text/javascript" src="EasyDEX-GUI/assets/scripts/config.js"></script>
<script type="text/javascript" src="bluebird.min.js"></script> <script type="text/javascript" src="bluebird.min.js"></script>
<script type="text/javascript" src="loading.js"></script> <script type="text/javascript" src="loading.js"></script>
<script type="text/javascript" src="jRoll.min.js"></script> <script type="text/javascript" src="jRoll.min.js"></script>

4
gui/init.js

@ -17,7 +17,7 @@ $(document).ready(function() {
var portcheck; var portcheck;
function sartcheck() { function startcheck() {
portcheck = setInterval(function(){ portcheck = setInterval(function(){
Iguana_activehandle().then(function(result){ Iguana_activehandle().then(function(result){
console.log(result); console.log(result);
@ -37,5 +37,5 @@ $(document).ready(function() {
clearInterval(portcheck); clearInterval(portcheck);
} }
sartcheck(); startcheck();
}); });

11
gui/loading.js

@ -4,6 +4,7 @@ function IguanaAJAX(url, ajax_data) {
url: url, url: url,
type: 'POST', type: 'POST',
dataType: 'json', dataType: 'json',
timeout: 120000
//beforeSend: showLoadingImgFn //beforeSend: showLoadingImgFn
}) })
.fail(function(xhr, textStatus, error) { .fail(function(xhr, textStatus, error) {
@ -17,7 +18,7 @@ function Iguana_activehandle(callback) {
'agent': 'SuperNET', 'agent': 'SuperNET',
'method': 'activehandle' 'method': 'activehandle'
}, },
AjaxOutputData = IguanaAJAX('http://127.0.0.1:7778', ajax_data).done(function(data) { AjaxOutputData = IguanaAJAX('http://127.0.0.1:' + config.iguanaPort, ajax_data).done(function(data) {
//console.log(AjaxOutputData.responseText); //console.log(AjaxOutputData.responseText);
AjaxOutputData = JSON.parse(AjaxOutputData.responseText) AjaxOutputData = JSON.parse(AjaxOutputData.responseText)
//console.log(AjaxOutputData); //console.log(AjaxOutputData);
@ -31,7 +32,7 @@ function Iguana_activehandle(callback) {
console.log(textStatus); console.log(textStatus);
console.log(error); console.log(error);
}); });
}); });
} }
//Iguana_activehandle().then(function(result){ //Iguana_activehandle().then(function(result){
//console.log(result) //console.log(result)
@ -95,7 +96,7 @@ function EDEX_DEXnotarychains() {
'agent': 'dpow', 'agent': 'dpow',
'method': 'notarychains' 'method': 'notarychains'
}, },
AjaxOutputData = IguanaAJAX('http://127.0.0.1:7778', ajax_data).done(function(data) { AjaxOutputData = IguanaAJAX('http://127.0.0.1:' + config.iguanaPort, ajax_data).done(function(data) {
//console.log(AjaxOutputData.responseText); //console.log(AjaxOutputData.responseText);
AjaxOutputData = JSON.parse(AjaxOutputData.responseText); AjaxOutputData = JSON.parse(AjaxOutputData.responseText);
//console.log(AjaxOutputData); //console.log(AjaxOutputData);
@ -124,7 +125,7 @@ function EDEX_DEXgetinfoAll(skip, minNotaries) {
'method': 'notarychains' 'method': 'notarychains'
}, },
tmp_index = 0, tmp_index = 0,
get_dex_notarychains = IguanaAJAX('http://127.0.0.1:7778', ajax_data).done(function(data) { get_dex_notarychains = IguanaAJAX('http://127.0.0.1:' + config.iguanaPort, ajax_data).done(function(data) {
get_dex_notarychains = JSON.parse(get_dex_notarychains.responseText); get_dex_notarychains = JSON.parse(get_dex_notarychains.responseText);
if (minNotaries > get_dex_notarychains.length) { // if config value exceeds total num of notaries if (minNotaries > get_dex_notarychains.length) { // if config value exceeds total num of notaries
minNotaries = get_dex_notarychains.length; minNotaries = get_dex_notarychains.length;
@ -144,7 +145,7 @@ function EDEX_DEXgetinfoAll(skip, minNotaries) {
console.log(ajax_data); console.log(ajax_data);
if (coin_value !== 'MESH' || coin_value !== 'CEAL') { if (coin_value !== 'MESH' || coin_value !== 'CEAL') {
var getinfo_each_chain = IguanaAJAX('http://127.0.0.1:7778', ajax_data).done(function(data) { var getinfo_each_chain = IguanaAJAX('http://127.0.0.1:' + config.iguanaPort, ajax_data).done(function(data) {
getinfo_each_chain = JSON.parse(getinfo_each_chain.responseText); getinfo_each_chain = JSON.parse(getinfo_each_chain.responseText);
console.log(getinfo_each_chain); console.log(getinfo_each_chain);

2
main.js

@ -101,7 +101,7 @@ server.listen(appConfig.iguanaAppPort, function() {
console.log('guiapp and sockets.io are listening on port ' + appConfig.iguanaAppPort + '!'); console.log('guiapp and sockets.io are listening on port ' + appConfig.iguanaAppPort + '!');
}); });
io.set('origins', 'http://127.0.0.1:17777'); // set origin io.set('origins', 'http://127.0.0.1:' + appConfig.iguanaAppPort); // set origin
io.on('connection', function(client) { io.on('connection', function(client) {
console.log('EDEX GUI is connected...'); console.log('EDEX GUI is connected...');

9
routes/cache.js

@ -561,7 +561,14 @@ cache.one = function(req, res, next) {
getAddresses(coin); getAddresses(coin);
} }
} else { } else {
callStack[coin] = callStack[coin] + (coin === 'BTC' ? callsArray.length : callsArray.length - 2); var callsArrayBTC = callsArray.length; // restrict BTC and SYS only to listunspent and listtransactions calls
if (callsArray.indexOf('getbalance') > - 1) {
callsArrayBTC--;
}
if (callsArray.indexOf('refresh') > - 1) {
callsArrayBTC--;
}
callStack[coin] = callStack[coin] + (coin === 'BTC' || coin === 'SYS' ? callsArrayBTC : callsArray.length);
console.log(coin + ' stack len ' + callStack[coin]); console.log(coin + ' stack len ' + callStack[coin]);
execDEXRequests(coin, address); execDEXRequests(coin, address);

90
routes/shepherd.js

@ -87,6 +87,49 @@ shepherd.appConfig = {
} }
}; };
shepherd.loadLocalConfig = function() {
if (fs.existsSync(iguanaDir + '/config.json')) {
var localAppConfig = fs.readFileSync(iguanaDir + '/config.json', 'utf8');
console.log('app config set from local file');
// find diff between local and hardcoded configs
// append diff to local config
var compareJSON = function(obj1, obj2) {
var result = {};
for (var i in obj1) {
if (!obj2.hasOwnProperty(i)) {
result[i] = obj1[i];
}
}
return result;
};
var compareConfigs = compareJSON(shepherd.appConfig, JSON.parse(localAppConfig));
if (Object.keys(compareConfigs).length) {
var newConfig = Object.assign(JSON.parse(localAppConfig), compareConfigs);
console.log('config diff is found, updating local config');
console.log('config diff:');
console.log(compareConfigs);
shepherd.saveLocalAppConf(newConfig);
return newConfig;
} else {
return JSON.parse(localAppConfig);
}
} else {
console.log('local config file is not found!');
shepherd.saveLocalAppConf(shepherd.appConfig);
return shepherd.appConfig;
}
};
shepherd.appConfig = shepherd.loadLocalConfig();
console.log('iguana dir: ' + iguanaDir); console.log('iguana dir: ' + iguanaDir);
console.log('iguana bin: ' + iguanaBin); console.log('iguana bin: ' + iguanaBin);
console.log('--------------------------') console.log('--------------------------')
@ -114,7 +157,7 @@ var mock = require('./mock');
// expose sockets obj // expose sockets obj
shepherd.setIO = function(io) { shepherd.setIO = function(io) {
shepherd.io = io; shepherd.io = io;
cache.setVar('io', io); cache.setVar('io', io);
}; };
cache.setVar('iguanaDir', iguanaDir); cache.setVar('iguanaDir', iguanaDir);
@ -149,7 +192,7 @@ shepherd.delete('/groom', function(req, res, next) {
* params: filename, payload * params: filename, payload
*/ */
shepherd.post('/groom', function(req, res) { shepherd.post('/groom', function(req, res) {
cache.groomPost(req, res, next); cache.groomPost(req, res, next);
}); });
/* /*
@ -465,47 +508,6 @@ shepherd.get('/kick', function(req, res, next) {
} }
}); });
shepherd.loadLocalConfig = function() {
if (fs.existsSync(iguanaDir + '/config.json')) {
var localAppConfig = fs.readFileSync(iguanaDir + '/config.json', 'utf8');
console.log('app config set from local file');
// find diff between local and hardcoded configs
// append diff to local config
var compareJSON = function(obj1, obj2) {
var result = {};
for (var i in obj1) {
if (!obj2.hasOwnProperty(i)) {
result[i] = obj1[i];
}
}
return result;
};
var compareConfigs = compareJSON(shepherd.appConfig, JSON.parse(localAppConfig));
if (Object.keys(compareConfigs).length) {
var newConfig = Object.assign(JSON.parse(localAppConfig), compareConfigs);
console.log('config diff is found, updating local config');
console.log('config diff:');
console.log(compareConfigs);
shepherd.saveLocalAppConf(newConfig);
return newConfig;
} else {
return JSON.parse(localAppConfig);
}
} else {
console.log('local config file is not found!');
shepherd.saveLocalAppConf(shepherd.appConfig);
return shepherd.appConfig;
}
};
shepherd.readDebugLog = function(fileLocation, lastNLines) { shepherd.readDebugLog = function(fileLocation, lastNLines) {
return new Promise( return new Promise(
function(resolve, reject) { function(resolve, reject) {
@ -609,10 +611,12 @@ function herder(flock, data) {
process.exit(2); process.exit(2);
} }
console.log('iguana core port ' + shepherd.appConfig.iguanaCorePort);
pm2.start({ pm2.start({
script: iguanaBin, // path to binary script: iguanaBin, // path to binary
name: 'IGUANA', name: 'IGUANA',
exec_mode : 'fork', exec_mode : 'fork',
args: ['-port=' + shepherd.appConfig.iguanaCorePort],
cwd: iguanaDir //set correct iguana directory cwd: iguanaDir //set correct iguana directory
}, function(err, apps) { }, function(err, apps) {
pm2.disconnect(); // Disconnect from PM2 pm2.disconnect(); // Disconnect from PM2

Loading…
Cancel
Save