Browse Source

Merge branch 'master' of https://github.com/SuperNETorg/Agama into dl

all-modes
pbca26 8 years ago
parent
commit
67f5920659
  1. BIN
      gui/agama-icon-small.png
  2. 43
      gui/agama-icon.svg
  3. 20
      gui/index.html
  4. 58
      gui/init.js
  5. 80
      gui/loading.css
  6. 82
      gui/loading.js
  7. 7
      main.js
  8. 1
      package.json
  9. 261
      routes/shepherd.js

BIN
gui/agama-icon-small.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

43
gui/agama-icon.svg

@ -0,0 +1,43 @@
<svg width="62" height="62" xmlns="http://www.w3.org/2000/svg">
<g>
<title>background</title>
<rect fill="none" id="canvas_background" height="64" width="64" y="-1" x="-1"/>
</g>
<g>
<title>Layer 1</title>
<g id="svg_1">
<g id="svg_2">
<path id="svg_3" d="m-95.883,25.261" fill="#FFFFFF"/>
</g>
<g id="svg_4">
<g id="svg_5">
<g id="svg_6">
<polyline id="svg_7" points="5.016998291015625,16.1199951171875 5.016998291015625,16.1199951171875 5.016998291015625,16.1199951171875 5.016998291015625,16.1199951171875 5.016998291015625,16.1199951171875 5.016998291015625,16.1199951171875 5.016998291015625,16.1199951171875 5.016998291015625,16.1199951171875 5.016998291015625,16.1199951171875 5.016998291015625,16.1199951171875 " fill="none"/>
</g>
</g>
<g id="svg_8">
<g id="svg_9">
<polyline id="svg_10" points="5.016998291015625,16.1199951171875 5.016998291015625,16.1199951171875 5.016998291015625,16.1199951171875 5.016998291015625,16.1199951171875 5.016998291015625,16.1199951171875 5.016998291015625,16.1199951171875 5.016998291015625,16.1199951171875 5.016998291015625,16.1199951171875 " fill="none"/>
</g>
</g>
<g id="svg_11">
<g id="svg_12">
<polyline id="svg_13" points="5.016998291015625,16.1199951171875 5.016998291015625,16.1199951171875 5.016998291015625,16.1199951171875 5.016998291015625,16.1199951171875 " fill="none"/>
</g>
</g>
<g id="svg_14">
<g id="svg_15">
<path id="svg_16" d="m5.017,16.12"/>
</g>
</g>
</g>
<path id="svg_17" d="m25.98,50.215c-2.344,-0.536 -3.68,-2.914 -3.097,-4.579c-6.44,3.197 -12.483,2.971 -18.131,-0.678c0.041,0.104 0.082,0.208 0.124,0.312c6.681,10.741 16.851,15.481 30.51,14.221c3.236,-7.521 3.861,-13.971 1.874,-19.351c-1.248,-1.697 -3.004,-1.71 -5.268,-0.041c-0.961,0.561 -1.489,3.06 -1.584,7.499c-0.266,1.98 -1.743,2.853 -4.428,2.617" fill="#FCC414" clip-rule="evenodd" fill-rule="evenodd"/>
<path id="svg_18" d="m4.752,44.958c5.648,3.649 11.691,3.875 18.131,0.678c0.16,-0.457 0.464,-0.86 0.932,-1.157c2.521,-1.906 3.361,-3.856 2.521,-5.85c-0.85,-3.058 -4.675,-4.436 -11.473,-4.137c-3.756,0.08 -5.555,-1.439 -5.397,-4.557c0.498,-2.718 1.92,-4.086 4.266,-4.105c0.537,-0.086 1.049,-0.066 1.537,0.058c-3.75,-4.456 -5.289,-9.947 -4.617,-16.473c-0.159,0.142 -0.316,0.287 -0.473,0.433c-9.212,9.231 -11.02,20.934 -5.427,35.11" fill="#F59E1B" clip-rule="evenodd" fill-rule="evenodd"/>
<path id="svg_19" d="m15.267,25.888c0.896,0.229 1.709,0.813 2.438,1.752c2.473,1.993 4.859,2.661 7.159,2.004c1.945,-0.811 2.463,-2.33 1.552,-4.557c-1.062,-1.742 -2.796,-3.39 -5.204,-4.945c-1.717,-1.979 -1.544,-3.929 0.517,-5.85c1.455,-1.012 2.964,-1.12 4.525,-0.323c0.666,0.23 1.268,1.105 1.805,2.623c-0.693,-7.092 -0.405,-12.033 0.862,-14.824c-7.258,0.684 -13.349,3.233 -18.273,7.647c-0.67,6.526 0.869,12.017 4.619,16.473" fill="#EC6922" clip-rule="evenodd" fill-rule="evenodd"/>
<path id="svg_20" d="m28.06,16.592c0.302,0.852 0.583,1.906 0.845,3.162c0.582,2.774 1.498,4.595 2.747,5.462c1.194,0.532 1.899,0.15 2.117,-1.147c0.123,-1.364 -0.001,-3.055 -0.372,-5.074c-0.393,-3.504 0.857,-5.282 3.749,-5.333c2.727,0.436 3.794,1.923 3.2,4.46c1.971,-3.824 6.071,-6.31 12.301,-7.458c-5.227,-6.048 -13.135,-9.013 -23.724,-8.896c-1.268,2.791 -1.555,7.732 -0.863,14.824" fill="#383C8F" clip-rule="evenodd" fill-rule="evenodd"/>
<path id="svg_21" d="m40.346,18.122c-1.623,2.394 -2.765,4.452 -3.426,6.173c-0.578,1.829 -0.481,3.122 0.291,3.878c2.344,1.144 4.701,-2.734 7.004,-4.736c1.918,-1.668 4.619,-0.639 5.277,2.118c0.264,1.68 -0.316,2.863 -1.743,3.549c5.066,-0.177 8.928,2.53 11.585,8.121l-0.003,-0.301c0.798,-11.687 -1.249,-20.719 -6.399,-25.925c-0.094,-0.113 -0.189,-0.225 -0.285,-0.336c-6.23,1.149 -10.33,3.635 -12.301,7.459" fill="#0FA8E0" clip-rule="evenodd" fill-rule="evenodd"/>
<path id="svg_22" d="m46.195,29.595c-2.898,0.535 -4.848,1.182 -5.85,1.94c-1.47,1.845 -1.297,3.45 0.517,4.816c4.689,5.427 6.13,13.785 4.845,23.139l14.131,0.072l-0.505,-22.337c-2.657,-5.591 -6.519,-8.298 -11.585,-8.121c-0.437,0.211 -0.955,0.375 -1.553,0.491" fill="#61C1D2" clip-rule="evenodd" fill-rule="evenodd"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 4.1 KiB

20
gui/index.html

@ -13,14 +13,22 @@
<script type="text/javascript" src="jRoll.min.js"></script>
<script>if (window.module) module = window.module;</script>
</head>
<body>
<body class="agamaMode">
<div class="text-center">
<div class="loader-block">
<div id="loading_status_text">Starting Wallet. Please wait...</div>
<div id="loading_sub_status_text"></div>
<div id="loading_sub_status_output_text"></div>
<!--div id="normalStart">
<div class="loader-block">
<div id="loading_status_text">Starting Wallet. Please wait...</div>
<div id="loading_sub_status_text"></div>
<div id="loading_sub_status_output_text"></div>
</div>
<div id="pulse" class="pulse-loader"></div>
</div-->
<div id="agamaMode">
<img src="agama-icon.svg" class="agama-logo" alt="Agama Wallet" width="80" height="100" />
<div id="agamaModeStatus">Choose Agama mode</div>
<button onClick="closeMainWindow()" class="btn btn-primary">Native only</button>
<button onClick="normalStart()" class="btn btn-primary">Normal start</button>
</div>
<div id="pulse" class="pulse-loader"></div>
</div>
<script type="text/javascript" src="init.js"></script>
</body>

58
gui/init.js

@ -1,48 +1,52 @@
$(document).ready(function() {
const remote = require('electron').remote;
var window = remote.getCurrentWindow();
var appConf = remote.getCurrentWindow().appConfig;
$('#pulse').jRoll({
radius: 100,
animation: 'pulse'
});
$('#loading_status_text').text('Starting Iguana daemon...');
inititalWalletLoading();
GetAppConf(inititalWalletLoading);
$('#loading_status_text').text('Starting Wallet. Please wait...');
function inititalWalletLoading(appConf) {
if (appConf && !appConf.manualIguanaStart) {
StartIguana();
}
function inititalWalletLoading() {
// run iguana-less mode with no daemons startup
if (appConf && appConf.iguanaLessMode) {
// do something
} else { // run normal mode with 2 iguana instances started prior loading GUI
if (appConf && !appConf.manualIguanaStart) {
StartIguana();
}
var portcheck;
var portcheck;
function startcheck() {
portcheck = setInterval(function(){
Iguana_activehandle(appConf).then(function(result){
console.log(result);
function startcheck() {
portcheck = setInterval(function(){
Iguana_activehandle(appConf).then(function(result){
console.log(result);
if (result !== 'error') {
stopcheck();
if (result !== 'error') {
stopcheck();
if (appConf && appConf.useBasiliskInstance) {
StartIguana_Cache();
}
if (appConf && appConf.useBasiliskInstance) {
StartIguana_Cache();
$('#loading_status_text').text('Connecting to Basilisk Network...');
EDEX_DEXgetinfoAll(appConf.skipBasiliskNetworkCheck, appConf.minNotaries, appConf);
}
})
}, 2000);
}
$('#loading_status_text').text('Connecting to Basilisk Network...');
EDEX_DEXgetinfoAll(appConf.skipBasiliskNetworkCheck, appConf.minNotaries, appConf);
}
})
//var check = Iguana_activehandle();
//console.log(check[0])
}, 2000);
}
function stopcheck() {
clearInterval(portcheck);
}
function stopcheck() {
clearInterval(portcheck);
startcheck();
}
startcheck();
}
});

80
gui/loading.css

@ -25,4 +25,84 @@ body {
left: -100px;
margin: 80px 50px;
width: 400px !important;
}
body.agamaMode {
background-color: rgba(33, 33, 33, 0.85);
padding-top: 40px;
color: #fff;
}
.agama-logo {
padding-bottom: 20px;
}
#agamaModeStatus {
padding-bottom: 25px;
font-weight: bold;
font-size: 16px;
}
.btn-primary.focus,
.btn-primary:focus,
.btn-primary:hover,
.btn-primary:active,
.btn-primary.active {
background-color: #ffa726 !important;
border-color: #ffa726 !important;
}
.btn.active.focus,
.btn.active:focus,
.btn.focus,
.btn:active.focus,
.btn:active:focus,
.btn:focus {
outline: thin dotted;
outline: 5px auto -webkit-focus-ring-color;
outline-offset: -2px;
}
.btn {
padding: 6px 15px;
font-size: 14px;
line-height: 1.57142857;
border-radius: 3px;
-webkit-box-shadow: 0 1px 4px 0 rgba(0,0,0,.1);
box-shadow: 0 1px 4px 0 rgba(0,0,0,.1);
-webkit-transition: border .2s linear,color .2s linear,width .2s linear,background-color .2s linear;
-o-transition: border .2s linear,color .2s linear,width .2s linear,background-color .2s linear;
transition: border .2s linear,color .2s linear,width .2s linear,background-color .2s linear;
-webkit-font-smoothing: subpixel-antialiased;
font-weight: bold;
display: inline-block;
padding: 6px 15px;
margin-bottom: 0;
line-height: 1.57142857;
text-align: center;
white-space: nowrap;
vertical-align: middle;
-ms-touch-action: manipulation;
touch-action: manipulation;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
background-image: none;
border: 1px solid transparent;
border-radius: 3px;
}
.btn-primary {
color: #fff;
background-color: #FF6600;
border-color: #FF6600;
}
.btn:first-child {
margin-right: 20px;
}
.btn:last-child {
margin-left: 20px;
}

82
gui/loading.js

@ -1,3 +1,53 @@
function closeMainWindow() {
const remote = require('electron').remote;
const window = remote.getCurrentWindow();
window.createWindow('open');
window.hide();
}
function normalStart() {
const remote = require('electron').remote;
let appConf = remote.getCurrentWindow().appConfig;
appConf.iguanaLessMode = false;
// run iguana-less mode with no daemons startup
if (appConf && appConf.iguanaLessMode) {
// do something
} else { // run normal mode with 2 iguana instances started prior loading GUI
if (appConf && !appConf.manualIguanaStart) {
StartIguana();
}
var portcheck;
function startcheck() {
portcheck = setInterval(function() {
Iguana_activehandle(appConf).then(function(result){
console.log(result);
if (result !== 'error') {
stopcheck();
if (appConf && appConf.useBasiliskInstance) {
StartIguana_Cache();
}
$('#loading_status_text').text('Connecting to Basilisk Network...');
EDEX_DEXgetinfoAll(appConf.skipBasiliskNetworkCheck, appConf.minNotaries, appConf);
}
})
}, 2000);
}
function stopcheck() {
clearInterval(portcheck);
}
startcheck();
}
}
function IguanaAJAX(url, ajax_data, timeout) {
return $.ajax({
data: JSON.stringify(ajax_data),
@ -44,6 +94,8 @@ function StartIguana() {
var ajax_data = { 'herd': 'iguana'};
console.log(ajax_data);
$('#agamaModeStatus').text('Starting main iguana instance...');
$.ajax({
type: 'POST',
data: JSON.stringify(ajax_data),
@ -66,6 +118,8 @@ function StartIguana() {
}
function StartIguana_Cache() {
$('#agamaModeStatus').text('Starting basilisk iguana instance...');
var ajax_data = {
'mode': 'basilisk',
'coin': 'all'
@ -83,34 +137,6 @@ function StartIguana_Cache() {
});
}
function GetAppConf(cb) { // get iguana app conf
var ajax_data = { 'herd': 'iguana' },
data = false;
console.log(ajax_data);
$.ajax({
type: 'GET',
url: 'http://127.0.0.1:17777/shepherd/appconf'
})
.done(function(_data) {
console.log('== App Conf Data OutPut ==');
console.log(_data);
data = _data;
cb.call(this, data);
})
.fail(function(xhr, textStatus, error) {
// handle request failures
console.log(xhr.statusText);
if ( xhr.readyState == 0 ) {
}
console.log(textStatus);
console.log(error);
cb.call(this, data);
});
return data;
}
function EDEX_DEXgetinfoAll(skip, minNotaries, appConf) {
const remote = require('electron').remote;
var window = remote.getCurrentWindow();

7
main.js

@ -203,6 +203,7 @@ function createLoadingWindow() {
});
loadingWindow.createWindow = createWindow; // expose createWindow to front-end scripts
loadingWindow.appConfig = appConfig;
// load our index.html (i.e. easyDEX GUI)
loadingWindow.loadURL(`http://${appConfig.host}:${appConfig.agamaPort}/gui/`);
@ -233,7 +234,7 @@ function createLoadingWindow() {
app.on('ready', createLoadingWindow);
function createWindow (status) {
if ( status === 'open') {
if (status === 'open') {
require(path.join(__dirname, 'private/mainmenu'));
// initialise window
@ -307,10 +308,6 @@ function createWindow (status) {
shepherd.dumpCacheBeforeExit();
shepherd.quitKomodod();
// if komodod is under heavy load it may not respond to cli stop the first time
setInterval(function() {
shepherd.quitKomodod();
}, 100);
pm2.connect(true, function(err) {
console.log('connecting to pm2...');

1
package.json

@ -26,7 +26,6 @@
"adm-zip": "^0.4.7",
"bluebird": "^3.4.7",
"body-parser": "^1.15.2",
"corsproxy": "^1.5.0",
"electron": "^1.6.5",
"express": "^4.14.0",
"fix-path": "^2.1.0",

261
routes/shepherd.js

@ -26,6 +26,7 @@ var ps = require('ps-node'),
assetChainPorts = require('./ports.js'),
shepherd = express.Router(),
iguanaInstanceRegistry = {},
coindInstanceRegistry = {},
syncOnlyIguanaInstanceInfo = {},
syncOnlyInstanceInterval = -1,
guiLog = {},
@ -98,7 +99,8 @@ shepherd.appConfig = {
"cli": {
"passthru": false,
"default": false
}
},
"iguanaLessMode": false
};
shepherd.writeLog = function(data) {
@ -426,17 +428,31 @@ shepherd.post('/coinslist', function(req, res, next) {
});
// TODO: check if komodod is running
shepherd.quitKomodod = function(chain) {
shepherd.quitKomodod = function() {
// if komodod is under heavy load it may not respond to cli stop the first time
// exit komodod gracefully
console.log('exec ' + komodocliBin + (chain ? ' -ac_name=' + chain : '') + ' stop');
exec(komodocliBin + (chain ? ' -ac_name=' + chain : '') + ' stop', function(error, stdout, stderr) {
console.log(`stdout: ${stdout}`);
console.log(`stderr: ${stderr}`);
let coindExitInterval = {};
if (error !== null) {
console.log(`exec error: ${error}`);
}
});
for (let key in coindInstanceRegistry) {
const chain = key !== 'komodod' ? key : null;
coindExitInterval[key] = setInterval(function() {
console.log('exec ' + komodocliBin + (chain ? ' -ac_name=' + chain : '') + ' stop');
exec(komodocliBin + (chain ? ' -ac_name=' + chain : '') + ' stop', function(error, stdout, stderr) {
console.log(`stdout: ${stdout}`);
console.log(`stderr: ${stderr}`);
if (stdout.indexOf('stopping') > -1 ||
stdout.indexOf('EOF reached') > -1) {
clearInterval(coindExitInterval[key]);
}
if (error !== null) {
console.log(`exec error: ${error}`);
}
});
}, 100);
}
}
shepherd.getConf = function(chain) {
@ -642,7 +658,7 @@ shepherd.saveLocalAppConf = function(appSettings) {
shepherd.loadLocalConfig = function() {
if (fs.existsSync(`${iguanaDir}/config.json`)) {
let localAppConfig = fs.readFileSync(`${iguanaDir}/config.json`, 'utf8');
console.log('app config set from local file');
shepherd.writeLog('app config set from local file');
@ -662,7 +678,7 @@ shepherd.loadLocalConfig = function() {
if (localAppConfig) {
const compareConfigs = compareJSON(shepherd.appConfig, JSON.parse(localAppConfig));
if (Object.keys(compareConfigs).length) {
const newConfig = Object.assign(JSON.parse(localAppConfig), compareConfigs);
@ -947,15 +963,98 @@ shepherd.post('/forks', function(req, res, next) {
pm2.disconnect(); // Disconnect from PM2
if (err) {
throw err;
shepherd.writeLog(`iguana fork error: ${err}`);
console.log(`iguana fork error: ${err}`);
throw err;
}
});
});
});
});
/*
* type: GET
*
*/
shepherd.get('/InstantDEX/allcoins', function(req, res, next) {
// TODO: if only native return obj
// else query main iguana instance and return combined response
// http://localhost:7778/api/InstantDEX/allcoins?userpass=tmpIgRPCUser@1234
let successObj;
let nativeCoindList = [];
for (let key in coindInstanceRegistry) {
nativeCoindList.push(key === 'komodod' ? 'KMD' : key);
}
if (Object.keys(iguanaInstanceRegistry).length) {
// call to iguana
request({
url: `http://localhost:${shepherd.appConfig.iguanaCorePort}/api/InstantDEX/allcoins?userpass=${req.query.userpass}`,
method: 'GET'
}, function (error, response, body) {
if (response &&
response.statusCode &&
response.statusCode === 200) {
const _body = JSON.parse(body);
_body.native = nativeCoindList;
console.log(_body);
} else {
console.log('main iguana instance is not ready yet');
}
res.send(body);
});
} else {
successObj = {
'native': nativeCoindList,
'basilisk': [],
'full': []
};
res.end(JSON.stringify(successObj));
}
});
/*
* type: GET
*
*/
shepherd.get('/SuperNET/activehandle', function(req, res, next) {
// TODO: if only native return obj
// else query main iguana instance and return combined response
// http://localhost:7778/api/SuperNET/activehandle?userpass=tmpIgRPCUser@1234
let successObj;
if (Object.keys(iguanaInstanceRegistry).length) {
// call to iguana
request({
url: `http://localhost:${shepherd.appConfig.iguanaCorePort}/api/SuperNET/activehandle?userpass=${req.query.userpass}`,
method: 'GET'
}, function (error, response, body) {
if (response &&
response.statusCode &&
response.statusCode === 200) {
console.log(body);
} else {
console.log('main iguana instance is not ready yet');
}
res.send(body);
});
} else {
successObj = {
'pubkey': 'nativeonly',
'result': 'success',
'handle': '',
'status': Object.keys(coindInstanceRegistry).length ? 'unlocked' : 'locked',
'duration': 2507830
};
res.end(JSON.stringify(successObj));
}
});
/*
* type: GET
* params: pubkey
@ -1332,7 +1431,7 @@ shepherd.readDebugLog = function(fileLocation, lastNLines) {
const lines = data.trim().split('\n');
const lastLine = lines.slice(lines.length - lastNLines, lines.length).join('\n');
resolve(lastLine);
});
}
@ -1415,17 +1514,18 @@ function herder(flock, data) {
pm2.disconnect(); // Disconnect from PM2
if (err) {
throw err;
shepherd.writeLog(`iguana core port ${shepherd.appConfig.iguanaCorePort}`);
console.log(`iguana fork error: ${err}`);
throw err;
}
});
});
}
// TODO: notify gui that reindex/rescan param is used to reflect on the screen
if (flock === 'komodod') {
let kmdDebugLogLocation = (data.ac_name !== 'komodod' ? komodoDir + '/' + data.ac_name : komodoDir) + '/debug.log';
console.log('komodod flock selected...');
console.log(`selected data: ${data}`);
shepherd.writeLog('komodod flock selected...');
@ -1457,59 +1557,50 @@ function herder(flock, data) {
// Status is 'open' if currently in use or 'closed' if available
if (status === 'closed') {
// start komodod via exec
if (data.ac_name === 'komodod') {
const _customParamDict = {
'silent': '&',
'reindex': '-reindex',
'change': '-pubkey='
};
let _customParam = '';
if (data.ac_custom_param === 'silent' ||
data.ac_custom_param === 'reindex') {
_customParam = ` ${_customParamDict[data.ac_custom_param]}`;
} else if (data.ac_custom_param === 'change' && data.ac_custom_param_value) {
_customParam = ` ${_customParamDict[data.ac_custom_param]}${data.ac_custom_param_value}`;
}
console.log(`exec ${komododBin} ${data.ac_options.join(' ')}${_customParam}`);
shepherd.writeLog(`exec ${komododBin} ${data.ac_options.join(' ')}${_customParam}`);
exec(`${komododBin} ${data.ac_options.join(' ')}${_customParam}`, {
maxBuffer: 1024 * 10000 // 10 mb
}, function(error, stdout, stderr) {
// console.log('stdout: ' + stdout);
// console.log('stderr: ' + stderr);
shepherd.writeLog(`stdout: ${stdout}`);
shepherd.writeLog(`stderr: ${stderr}`);
const _customParamDict = {
'silent': '&',
'reindex': '-reindex',
'change': '-pubkey=',
'datadir': '-datadir=',
'rescan': '-rescan'
};
let _customParam = '';
if (data.ac_custom_param === 'silent' ||
data.ac_custom_param === 'reindex' ||
data.ac_custom_param === 'rescan') {
_customParam = ` ${_customParamDict[data.ac_custom_param]}`;
} else if (data.ac_custom_param === 'change' && data.ac_custom_param_value) {
_customParam = ` ${_customParamDict[data.ac_custom_param]}${data.ac_custom_param_value}`;
}
if (error !== null) {
console.log(`exec error: ${error}`)
shepherd.writeLog(`exec error: ${error}`);
}
});
} else {
pm2.connect(true, function(err) { // start up pm2 god
if (err) {
console.error(err);
process.exit(2);
console.log(`exec ${komododBin} ${data.ac_options.join(' ')}${_customParam}`);
shepherd.writeLog(`exec ${komododBin} ${data.ac_options.join(' ')}${_customParam}`);
const isChain = data.ac_name.match(/^[A-Z]*$/);
const coindACParam = isChain ? ` -ac_name=${data.ac_name} ` : '';
console.log('daemon param ' + data.ac_custom_param);
coindInstanceRegistry[data.ac_name] = true;
exec(`${komododBin} ${coindACParam}${data.ac_options.join(' ')}${_customParam}`, {
maxBuffer: 1024 * 10000 // 10 mb
}, function(error, stdout, stderr) {
shepherd.writeLog(`stdout: ${stdout}`);
shepherd.writeLog(`stderr: ${stderr}`);
if (error !== null) {
console.log(`exec error: ${error}`);
shepherd.writeLog(`exec error: ${error}`);
if (error.toString().indexOf('using -reindex') > -1) {
cache.io.emit('service', {
'komodod': {
'error': 'run -reindex'
}
});
}
pm2.start({
script: komododBin, // path to binary
name: data.ac_name, // REVS, USD, EUR etc.
exec_mode : 'fork',
cwd: komodoDir,
args: data.ac_options
}, function(err, apps) {
shepherd.writeLog(`komodod fork started ${data.ac_name} ${JSON.stringify(data.ac_options)}`);
pm2.disconnect(); // Disconnect from PM2
if (err)
throw err;
});
});
}
}
});
} else {
console.log(`port ${_port} (${data.ac_name}) is already in use`);
shepherd.writeLog(`port ${_port} (${data.ac_name}) is already in use`);
@ -1538,7 +1629,7 @@ function herder(flock, data) {
pm2.start({
script: zcashdBin, // path to binary
name: data.ac_name, // REVS, USD, EUR etc.
exec_mode : 'fork',
exec_mode: 'fork',
cwd: zcashDir,
args: data.ac_options
}, function(err, apps) {
@ -1550,30 +1641,6 @@ function herder(flock, data) {
});
});
}
// deprecated, to be removed
if (flock === 'corsproxy') {
console.log('corsproxy flock selected...');
console.log(`selected data: ${data}`);
pm2.connect(true,function(err) { //start up pm2 god
if (err) {
console.error(err);
process.exit(2);
}
pm2.start({
script: CorsProxyBin, // path to binary
name: 'CORSPROXY',
exec_mode : 'fork',
cwd: iguanaDir
}, function(err, apps) {
pm2.disconnect(); // Disconnect from PM2
if (err)
throw err;
});
});
}
}
function slayer(flock) {
@ -1646,14 +1713,14 @@ function setConf(flock) {
switch (flock) {
case 'komodod':
DaemonConfPath = `${komodoDir}/komodo.conf`;
if (os.platform() === 'win32') {
DaemonConfPath = path.normalize(DaemonConfPath);
}
break;
case 'zcashd':
DaemonConfPath = `${ZcashDir}/zcash.conf`;
if (os.platform() === 'win32') {
DaemonConfPath = path.normalize(DaemonConfPath);
}
@ -1703,11 +1770,11 @@ function setConf(flock) {
const RemoveLines = function() {
return new Promise(function(resolve, reject) {
const result = 'RemoveLines is done'
const result = 'RemoveLines is done';
fs.readFile(DaemonConfPath, 'utf8', function(err, data) {
if (err) {
shepherd.writeLog(`setconf error '${err}`);
shepherd.writeLog(`setconf error ${err}`);
return console.log(err);
}
@ -1930,7 +1997,7 @@ function formatBytes(bytes, decimals) {
return '0 Bytes';
const k = 1000,
dm = decimals + 1 || 3,
dm = (decimals + 1) || 3,
sizes = [
'Bytes',
'KB',

Loading…
Cancel
Save