|
|
@ -15,7 +15,8 @@ const electron = require('electron'), |
|
|
|
pm2 = require('pm2'), |
|
|
|
request = require('request'), |
|
|
|
async = require('async'), |
|
|
|
rimraf = require('rimraf'); |
|
|
|
rimraf = require('rimraf'), |
|
|
|
portscanner = require('portscanner'); |
|
|
|
|
|
|
|
Promise = require('bluebird'); |
|
|
|
|
|
|
@ -23,6 +24,7 @@ const fixPath = require('fix-path'); |
|
|
|
var ps = require('ps-node'), |
|
|
|
setconf = require('../private/setconf.js'), |
|
|
|
kmdcli = require('../private/kmdcli.js'), |
|
|
|
assetChainPorts = require('./ports.js') |
|
|
|
shepherd = express.Router(); |
|
|
|
|
|
|
|
// IGUANA FILES AND CONFIG SETTINGS
|
|
|
@ -305,10 +307,7 @@ shepherd.post('/debuglog', function(req, res) { |
|
|
|
*/ |
|
|
|
shepherd.post('/herd', function(req, res) { |
|
|
|
console.log('======= req.body ======='); |
|
|
|
//console.log(req);
|
|
|
|
console.log(req.body); |
|
|
|
//console.log(req.body.herd);
|
|
|
|
//console.log(req.body.options);
|
|
|
|
|
|
|
|
herder(req.body.herd, req.body.options); |
|
|
|
|
|
|
@ -320,52 +319,12 @@ shepherd.post('/herd', function(req, res) { |
|
|
|
res.end(JSON.stringify(obj)); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
* |
|
|
|
* ajax_data = { 'command': 'getinfo' }; |
|
|
|
* |
|
|
|
* console.log(ajax_data); |
|
|
|
* $.ajax({ |
|
|
|
* async: false, |
|
|
|
* type: 'POST', |
|
|
|
* data: JSON.stringify(ajax_data), |
|
|
|
* url: 'http://127.0.0.1:17777/shepherd/kmdcli', |
|
|
|
* contentType: 'application/json', // send as JSON
|
|
|
|
* success: function(data, textStatus, jqXHR) { |
|
|
|
* var AjaxOutputData = JSON.parse(data); |
|
|
|
* console.log(AjaxOutputData); |
|
|
|
* }, |
|
|
|
* error: function(xhr, textStatus, error) { |
|
|
|
* console.log(xhr.statusText); |
|
|
|
* console.log(textStatus); |
|
|
|
* console.log(error); |
|
|
|
* } |
|
|
|
* }); |
|
|
|
* |
|
|
|
*/ |
|
|
|
/*shepherd.post('/kmdcli', function(req, res) { |
|
|
|
console.log('======= req.body ======='); |
|
|
|
//console.log(req);
|
|
|
|
console.log(req.body); |
|
|
|
console.log(req.body.command); |
|
|
|
|
|
|
|
kmdcli.command(req.body.command, function(err, command) { |
|
|
|
console.log(command); |
|
|
|
res.end(JSON.stringify(command)); |
|
|
|
}); |
|
|
|
});*/ |
|
|
|
|
|
|
|
/* |
|
|
|
* type: POST |
|
|
|
* params: herdname |
|
|
|
*/ |
|
|
|
shepherd.post('/herdlist', function(req, res) { |
|
|
|
//console.log('======= req.body =======');
|
|
|
|
//console.log(req);
|
|
|
|
//console.log(req.body);
|
|
|
|
console.log(req.body.herdname); |
|
|
|
//console.log(req.body.options);
|
|
|
|
|
|
|
|
pm2.connect(true, function(err) { |
|
|
|
if (err) throw err; // TODO: proper error handling
|
|
|
@ -394,9 +353,7 @@ shepherd.post('/herdlist', function(req, res) { |
|
|
|
*/ |
|
|
|
shepherd.post('/slay', function(req, res) { |
|
|
|
console.log('======= req.body ======='); |
|
|
|
//console.log(req);
|
|
|
|
console.log(req.body); |
|
|
|
//console.log(req.body.slay);
|
|
|
|
|
|
|
|
slayer(req.body.slay); |
|
|
|
var obj = { |
|
|
@ -412,9 +369,7 @@ shepherd.post('/slay', function(req, res) { |
|
|
|
*/ |
|
|
|
shepherd.post('/setconf', function(req, res) { |
|
|
|
console.log('======= req.body ======='); |
|
|
|
//console.log(req);
|
|
|
|
console.log(req.body); |
|
|
|
//console.log(req.body.chain);
|
|
|
|
|
|
|
|
if (os.platform() === 'win32' && req.body.chain == 'komodod') { |
|
|
|
setkomodoconf = spawn(path.join(__dirname, '../assets/bin/win64/genkmdconf.bat')); |
|
|
@ -435,9 +390,7 @@ shepherd.post('/setconf', function(req, res) { |
|
|
|
*/ |
|
|
|
shepherd.post('/getconf', function(req, res) { |
|
|
|
console.log('======= req.body ======='); |
|
|
|
//console.log(req);
|
|
|
|
console.log(req.body); |
|
|
|
//console.log(req.body.chain);
|
|
|
|
|
|
|
|
var confpath = getConf(req.body.chain); |
|
|
|
console.log('got conf path is:'); |
|
|
@ -699,7 +652,14 @@ function herder(flock, data) { |
|
|
|
console.log('komodod debug.log access err: ' + e); |
|
|
|
} |
|
|
|
|
|
|
|
// get komodod instance port
|
|
|
|
var _port = assetChainPorts[data.ac_name]; |
|
|
|
|
|
|
|
try { |
|
|
|
// check if komodod instance is already running
|
|
|
|
portscanner.checkPortStatus(_port, '127.0.0.1', function(error, status) { |
|
|
|
// Status is 'open' if currently in use or 'closed' if available
|
|
|
|
if (status === 'closed') { |
|
|
|
pm2.connect(true, function(err) { // start up pm2 god
|
|
|
|
if (err) { |
|
|
|
console.error(err); |
|
|
@ -712,13 +672,16 @@ function herder(flock, data) { |
|
|
|
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; |
|
|
|
}); |
|
|
|
}); |
|
|
|
} else { |
|
|
|
console.log('port ' + _port + ' (' + data.ac_name + ') is already in use'); |
|
|
|
} |
|
|
|
}); |
|
|
|
} catch(e) { |
|
|
|
console.log('failed to start komodod err: ' + e); |
|
|
|
} |
|
|
@ -741,7 +704,6 @@ function herder(flock, data) { |
|
|
|
exec_mode : 'fork', |
|
|
|
cwd: zcashDir, |
|
|
|
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) |
|
|
@ -778,7 +740,6 @@ function slayer(flock) { |
|
|
|
console.log(flock); |
|
|
|
|
|
|
|
pm2.delete(flock, function(err, ret) { |
|
|
|
//console.log(err);
|
|
|
|
pm2.disconnect(); |
|
|
|
console.log(ret); |
|
|
|
}); |
|
|
@ -882,8 +843,6 @@ function setConf(flock) { |
|
|
|
var result = 'CheckConf is done'; |
|
|
|
|
|
|
|
setconf.status(DaemonConfPath, function(err, status) { |
|
|
|
//console.log(status[0]);
|
|
|
|
//console.log(status[0].rpcuser);
|
|
|
|
var rpcuser = function() { |
|
|
|
return new Promise(function(resolve, reject) { |
|
|
|
var result = 'checking rpcuser...'; |
|
|
@ -901,7 +860,6 @@ function setConf(flock) { |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
//console.log(result)
|
|
|
|
resolve(result); |
|
|
|
}); |
|
|
|
} |
|
|
@ -923,7 +881,6 @@ function setConf(flock) { |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
//console.log(result)
|
|
|
|
resolve(result); |
|
|
|
}); |
|
|
|
} |
|
|
@ -943,7 +900,6 @@ function setConf(flock) { |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
//console.log(result)
|
|
|
|
resolve(result); |
|
|
|
}); |
|
|
|
} |
|
|
@ -970,7 +926,6 @@ function setConf(flock) { |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
//console.log(result)
|
|
|
|
resolve(result); |
|
|
|
}); |
|
|
|
} |
|
|
@ -980,7 +935,7 @@ function setConf(flock) { |
|
|
|
return rpcpass(); |
|
|
|
}) |
|
|
|
.then(server) |
|
|
|
.then(addnode) |
|
|
|
.then(addnode); |
|
|
|
}); |
|
|
|
|
|
|
|
setTimeout(function() { |
|
|
|