Browse Source

Merge pull request #104 from pbca26/master

app
all-modes
pbca26 8 years ago
committed by GitHub
parent
commit
ac82e2972b
  1. 2
      gui/EasyDEX-GUI
  2. 5
      main.js
  3. 5
      routes/cache.js
  4. 108
      routes/shepherd.js

2
gui/EasyDEX-GUI

@ -1 +1 @@
Subproject commit 59ff487c1f068700d381b07a4e873d2ab9d7c86d
Subproject commit 04af9b16553cee3ca7cba950ebf1072f98ee0ece

5
main.js

@ -21,7 +21,7 @@ var express = require('express'),
pm2 = require('pm2'),
cluster = require('cluster'),
numCPUs = require('os').cpus().length,
coincli = require('./private/coincli.js'),
//coincli = require('./private/coincli.js'),
ipc = require('electron').ipcMain;
Promise = require('bluebird');
@ -41,6 +41,7 @@ var shepherd = require('./routes/shepherd'),
if (appConfig.killIguanaOnStart) {
var iguanaGrep;
if (os.platform() === 'darwin') {
iguanaGrep = "ps -p $(ps -A | grep -m1 iguana | awk '{print $1}') | grep -i iguana";
}
@ -53,7 +54,7 @@ if (appConfig.killIguanaOnStart) {
exec(iguanaGrep, function(error, stdout, stderr) {
if (stdout.indexOf('iguana') > -1) {
console.log('found another iguana process(es)');
var pkillCmd = os.platform() === 'win32' ? 'taskkill /f /im iguana.exe' : 'pkill -9 iguana';
const pkillCmd = os.platform() === 'win32' ? 'taskkill /f /im iguana.exe' : 'pkill -9 iguana';
exec(pkillCmd, function(error, stdout, stderr) {
console.log(pkillCmd + ' is issued');

5
routes/cache.js

@ -141,6 +141,8 @@ cache.groomDelete = function(req, res, next) {
if (_filename) {
if (fs.existsSync(cache.iguanaDir + '/shepherd/cache-' + _filename + '.json')) {
inMemCache = {};
fs.unlink(cache.iguanaDir + '/shepherd/cache-' + _filename + '.json', function(err) {
if (err) {
const errorObj = {
@ -746,7 +748,8 @@ cache.one = function(req, res, next) {
'method': 'cache-one',
'status': 'in progress',
'iguanaAPI': {
'totalStackLength': callStack[coin]
'totalStackLength': callStack[coin],
'currentStackLength': callStack[coin]
}
}
}

108
routes/shepherd.js

@ -16,17 +16,18 @@ const electron = require('electron'),
request = require('request'),
async = require('async'),
rimraf = require('rimraf'),
portscanner = require('portscanner');
Promise = require('bluebird');
portscanner = require('portscanner'),
Promise = require('bluebird');
const fixPath = require('fix-path');
var ps = require('ps-node'),
setconf = require('../private/setconf.js'),
coincli = require('../private/coincli.js'),
//coincli = require('../private/coincli.js'),
assetChainPorts = require('./ports.js')
shepherd = express.Router(),
iguanaInstanceRegistry = {};
iguanaInstanceRegistry = {},
syncOnlyIguanaInstanceInfo = {},
syncOnlyInstanceInterval = -1;
// IGUANA FILES AND CONFIG SETTINGS
var iguanaConfsDirSrc = path.join(__dirname, '../assets/deps/confs'),
@ -110,6 +111,30 @@ shepherd.quitKomodod = function(chain) {
});
}
/*
* type: POST
* params: payload
*/
shepherd.post('/appconf', function(req, res, next) {
if (!req.body.payload) {
const errorObj = {
'msg': 'error',
'result': 'no payload provided'
};
res.end(JSON.stringify(errorObj));
} else {
shepherd.saveLocalAppConf(req.body.payload);
const errorObj = {
'msg': 'success',
'result': 'config saved'
};
res.end(JSON.stringify(errorObj));
}
});
shepherd.saveLocalAppConf = function(appSettings) {
var appConfFileName = iguanaDir + '/config.json';
@ -236,6 +261,69 @@ shepherd.setIO = function(io) {
cache.setVar('iguanaDir', iguanaDir);
cache.setVar('appConfig', shepherd.appConfig);
// fetch sync only forks info
shepherd.getSyncOnlyForksInfo = function() {
async.forEachOf(iguanaInstanceRegistry, function(data, port) {
if (iguanaInstanceRegistry[port].mode.indexOf('/sync') > -1) {
syncOnlyIguanaInstanceInfo[port] = {};
request({
url: 'http://localhost:' + port + '/api/bitcoinrpc/getinfo?userpass=tmpIgRPCUser@1234',
method: 'GET'
}, function (error, response, body) {
if (response && response.statusCode && response.statusCode === 200) {
// console.log(body);
try {
syncOnlyIguanaInstanceInfo[port].getinfo = JSON.parse(body);
} catch(e) {}
} else {
// TODO: error
}
});
request({
url: 'http://localhost:' + port + '/api/SuperNET/activehandle?userpass=tmpIgRPCUser@1234',
method: 'GET'
}, function (error, response, body) {
if (response && response.statusCode && response.statusCode === 200) {
// console.log(body);
try {
syncOnlyIguanaInstanceInfo[port].activehandle = JSON.parse(body);
} catch(e) {}
} else {
// TODO: error
}
});
syncOnlyIguanaInstanceInfo[port].registry = iguanaInstanceRegistry[port];
}
});
}
/*
* type: GET
*
*/
shepherd.get('/forks/info/start', function(req, res, next) {
var successObj = {
'msg': 'success',
'result': 'started'
};
res.end(JSON.stringify(successObj));
shepherd.getSyncOnlyForksInfo();
});
/*
* type: GET
*
*/
shepherd.get('/forks/info/show', function(req, res, next) {
var successObj = {
'msg': 'success',
'result': JSON.stringify(syncOnlyIguanaInstanceInfo)
};
res.end(JSON.stringify(successObj));
});
/*
* type: GET
*
@ -337,6 +425,16 @@ shepherd.post('/forks', function(req, res, next) {
};
cache.setVar('iguanaInstances', iguanaInstanceRegistry);
// get sync only forks info
if (syncOnlyInstanceInterval === -1) {
setTimeout(function() {
shepherd.getSyncOnlyForksInfo();
}, 5000);
setInterval(function() {
shepherd.getSyncOnlyForksInfo();
}, 20000);
}
var successObj = {
'msg': 'success',
'result': _port

Loading…
Cancel
Save