Browse Source

Merge pull request #82 from pbca26/master

async
all-modes
pbca26 8 years ago
committed by GitHub
parent
commit
e84ae1c88c
  1. 54
      gui/init.js
  2. 9
      gui/loading.js
  3. 2
      main.js
  4. 96
      routes/shepherd.js

54
gui/init.js

@ -7,35 +7,37 @@ $(document).ready(function() {
animation: 'pulse'
});
var appConf = GetAppConf();
$('#loading_status_text').text('Starting Iguana daemon...');
if (appConf && !appConf.manualIguanaStart) {
StartIguana();
}
GetAppConf(inititalWalletLoading);
var portcheck;
function startcheck() {
portcheck = setInterval(function(){
Iguana_activehandle().then(function(result){
console.log(result);
if (result !== 'error') {
stopcheck();
$('#loading_status_text').text('Connecting to Basilisk Network...');
EDEX_DEXgetinfoAll(appConf.skipBasiliskNetworkCheck, appConf.minNotaries);
}
})
//var check = Iguana_activehandle();
//console.log(check[0])
}, 2000);
}
function inititalWalletLoading(appConf) {
if (appConf && !appConf.manualIguanaStart) {
StartIguana();
}
function stopcheck() {
clearInterval(portcheck);
}
var portcheck;
startcheck();
function startcheck() {
portcheck = setInterval(function(){
Iguana_activehandle().then(function(result){
console.log(result);
if (result !== 'error') {
stopcheck();
$('#loading_status_text').text('Connecting to Basilisk Network...');
EDEX_DEXgetinfoAll(appConf.skipBasiliskNetworkCheck, appConf.minNotaries);
}
})
//var check = Iguana_activehandle();
//console.log(check[0])
}, 2000);
}
function stopcheck() {
clearInterval(portcheck);
}
startcheck();
}
});

9
gui/loading.js

@ -18,13 +18,15 @@ function Iguana_activehandle(callback) {
'agent': 'SuperNET',
'method': 'activehandle'
},
AjaxOutputData = IguanaAJAX('http://127.0.0.1:' + config.iguanaPort, ajax_data).done(function(data) {
AjaxOutputData = IguanaAJAX('http://127.0.0.1:7778', ajax_data).done(function(data) {
//$('#loading_status_text').text('Retrieving active handle...');
//console.log(AjaxOutputData.responseText);
AjaxOutputData = JSON.parse(AjaxOutputData.responseText)
//console.log(AjaxOutputData);
resolve(AjaxOutputData);
})
.fail(function(xhr, textStatus, error) {
// $('#loading_status_text').text('Retrieving active handle error!');
// handle request failures
console.log(xhr.statusText);
if ( xhr.readyState == 0 ) {
@ -63,13 +65,12 @@ function StartIguana() {
});
}
function GetAppConf() { // get iguana app conf
function GetAppConf(cb) { // get iguana app conf
var ajax_data = { 'herd': 'iguana' },
data = false;
console.log(ajax_data);
$.ajax({
async: false,
type: 'GET',
url: 'http://127.0.0.1:17777/shepherd/appconf'
})
@ -77,6 +78,7 @@ function GetAppConf() { // get iguana app conf
console.log('== App Conf Data OutPut ==');
console.log(_data);
data = _data;
cb.call(this, data);
})
.fail(function(xhr, textStatus, error) {
// handle request failures
@ -85,6 +87,7 @@ function GetAppConf() { // get iguana app conf
}
console.log(textStatus);
console.log(error);
cb.call(this, data);
});
return data;

2
main.js

@ -456,4 +456,4 @@ app.on('activate', function () {
if (mainWindow === null) {
//createWindow('open');
}
});
});

96
routes/shepherd.js

@ -322,9 +322,9 @@ shepherd.post('/herd', function(req, res) {
/*
*
*
* ajax_data = { 'command': 'getinfo' };
*
*
* console.log(ajax_data);
* $.ajax({
* async: false,
@ -342,7 +342,7 @@ shepherd.post('/herd', function(req, res) {
* console.log(error);
* }
* });
*
*
*/
/*shepherd.post('/kmdcli', function(req, res) {
console.log('======= req.body =======');
@ -422,7 +422,6 @@ shepherd.post('/setconf', function(req, res) {
setConf(req.body.chain);
}
var obj = {
'msg': 'success',
'result': 'result'
@ -619,9 +618,6 @@ shepherd.readDebugLog = function(fileLocation, lastNLines) {
};
function herder(flock, data) {
//console.log(flock);
//console.log(data);
if (data == undefined) {
data = 'none';
console.log('it is undefined');
@ -631,32 +627,6 @@ function herder(flock, data) {
console.log('iguana flock selected...');
console.log('selected data: ' + data);
//Make sure iguana isn't running before starting new process, kill it dammit!
// A simple pid lookup
/*ps.lookup({
command: 'iguana',
//arguments: '--debug',
}, function(err, resultList ) {
if (err) {
throw new Error( err );
}
resultList.forEach(function( process ){
if( process ){
console.log( 'PID: %s, COMMAND: %s, ARGUMENTS: %s', process.pid, process.command, process.arguments );
console.log(process.pid);
// A simple pid lookup
ps.kill( process.pid, function( err ) {
if (err) {
throw new Error( err );
}
else {
console.log( 'Process %s has been killed!', process.pid );
}
});
}
});
});*/
// MAKE SURE IGUANA DIR IS THERE FOR USER
mkdirp(iguanaDir, function(err) {
if (err)
@ -711,39 +681,47 @@ function herder(flock, data) {
}
if (flock === 'komodod') {
var kmdDebugLogLocation = komodoDir + '/debug.log';
var kmdDebugLogLocation = ( data.ac_name ? komodoDir + '/' + data.ac_name : komodoDir ) + '/debug.log';
console.log('komodod flock selected...');
console.log('selected data: ' + data);
// truncate debug.log
_fs.access(kmdDebugLogLocation, fs.constants.R_OK, function(err) {
if (err) {
console.log('error accessing ' + kmdDebugLogLocation);
} else {
console.log('truncate ' + kmdDebugLogLocation);
fs.unlink(kmdDebugLogLocation);
}
});
try {
_fs.access(kmdDebugLogLocation, fs.constants.R_OK, function(err) {
if (err) {
console.log('error accessing ' + kmdDebugLogLocation);
} else {
console.log('truncate ' + kmdDebugLogLocation);
fs.unlink(kmdDebugLogLocation);
}
});
} catch(e) {
console.log('komodod debug.log access err: ' + e);
}
pm2.connect(true, function(err) { // start up pm2 god
if (err) {
console.error(err);
process.exit(2);
}
try {
pm2.connect(true, function(err) { // start up pm2 god
if (err) {
console.error(err);
process.exit(2);
}
pm2.start({
script: komododBin, // path to binary
name: data.ac_name, // REVS, USD, EUR etc.
exec_mode : 'fork',
cwd: komodoDir,
args: data.ac_options
//args: ["-server", "-ac_name=USD", "-addnode=78.47.196.146"], //separate the params with commas
}, function(err, apps) {
pm2.disconnect(); // Disconnect from PM2
if (err)
throw err;
pm2.start({
script: komododBin, // path to binary
name: data.ac_name, // REVS, USD, EUR etc.
exec_mode : 'fork',
cwd: komodoDir,
args: data.ac_options
//args: ["-server", "-ac_name=USD", "-addnode=78.47.196.146"], //separate the params with commas
}, function(err, apps) {
pm2.disconnect(); // Disconnect from PM2
if (err)
throw err;
});
});
});
} catch(e) {
console.log('failed to start komodod err: ' + e);
}
}
if (flock === 'zcashd') {

Loading…
Cancel
Save