From 81a9a871953b131431fef0e8e1b7982f69d73981 Mon Sep 17 00:00:00 2001 From: pbca26 Date: Mon, 3 Jul 2017 00:28:48 +0300 Subject: [PATCH 1/6] run native only --- gui/init.js | 64 +++++++++++++------------ main.js | 8 +--- routes/shepherd.js | 117 ++++++++++++++++++++++++++++++++++++--------- 3 files changed, 130 insertions(+), 59 deletions(-) diff --git a/gui/init.js b/gui/init.js index 265e389..e09d705 100644 --- a/gui/init.js +++ b/gui/init.js @@ -7,42 +7,46 @@ $(document).ready(function() { animation: 'pulse' }); - $('#loading_status_text').text('Starting Iguana daemon...'); - GetAppConf(inititalWalletLoading); - function inititalWalletLoading(appConf) { - if (appConf && !appConf.manualIguanaStart) { - StartIguana(); - } - - var portcheck; - - function startcheck() { - portcheck = setInterval(function(){ - Iguana_activehandle(appConf).then(function(result){ - console.log(result); + $('#loading_status_text').text('Starting Wallet. Please wait...'); - if (result !== 'error') { - stopcheck(); - - if (appConf && appConf.useBasiliskInstance) { - StartIguana_Cache(); + function inititalWalletLoading(appConf) { + // run iguana-less mode with no daemons startup + if (appConf && appConf.iguanaLessMode) { + window.createWindow('open'); + window.hide(); + } 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); + } - $('#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(); } }); \ No newline at end of file diff --git a/main.js b/main.js index 22dbbe0..f0d0e0d 100644 --- a/main.js +++ b/main.js @@ -196,8 +196,8 @@ function createLoadingWindow() { // initialise window loadingWindow = new BrowserWindow({ - width: 500, - height: 300, + width: appConfig.iguanaLessMode ? 1 : 500, + height: appConfig.iguanaLessMode ? 1 : 300, frame: false, icon: iguanaIcon }); @@ -307,10 +307,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...'); diff --git a/routes/shepherd.js b/routes/shepherd.js index 746d25b..57262a9 100644 --- a/routes/shepherd.js +++ b/routes/shepherd.js @@ -25,6 +25,7 @@ var ps = require('ps-node'), assetChainPorts = require('./ports.js'), shepherd = express.Router(), iguanaInstanceRegistry = {}, + coindInstanceRegistry = {}, syncOnlyIguanaInstanceInfo = {}, syncOnlyInstanceInterval = -1, guiLog = {}, @@ -97,7 +98,8 @@ shepherd.appConfig = { "cli": { "passthru": false, "default": false - } + }, + "iguanaLessMode": false }; shepherd.writeLog = function(data) { @@ -273,17 +275,30 @@ 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) { + clearInterval(coindExitInterval[key]); + } + + if (error !== null) { + console.log(`exec error: ${error}`); + } + }); + }, 100); + } } shepherd.getConf = function(chain) { @@ -489,7 +504,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'); @@ -509,7 +524,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); @@ -803,6 +818,56 @@ shepherd.post('/forks', function(req, res, next) { }); }); +/* + * 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; + + if (Object.keys(iguanaInstanceRegistry).length) { + // call to iguana + } else { + let nativeCoindList = []; + + for (let key in coindInstanceRegistry) { + nativeCoindList.push(key === 'komodod' ? 'KMD' : key); + } + + successObj = { + 'native': nativeCoindList, + 'basilisk': [], + 'full': [] + }; + } + + console.log(successObj); + + 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 + const successObj = { + 'pubkey': 'nativeonly', + 'result': 'success', + 'handle': '', + 'status': Object.keys(coindInstanceRegistry).length ? 'unlocked' : 'locked', + 'duration': 2507830 + }; + + res.end(JSON.stringify(successObj)); +}); + /* * type: GET * params: pubkey @@ -1179,7 +1244,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); }); } @@ -1272,7 +1337,7 @@ function herder(flock, data) { 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...'); @@ -1304,11 +1369,12 @@ 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') { + //if (data.ac_name === 'komodod') { const _customParamDict = { 'silent': '&', 'reindex': '-reindex', - 'change': '-pubkey=' + 'change': '-pubkey=', + 'datadir': '-datadir=' }; let _customParam = ''; @@ -1322,7 +1388,12 @@ function herder(flock, data) { 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}`, { + const isChain = data.ac_name.match(/^[A-Z]*$/); + const coindACParam = isChain ? ` -ac_name=${data.ac_name} ` : ''; + console.log('coindAC ' + coindACParam); + + coindInstanceRegistry[data.ac_name] = true; + exec(`${komododBin} ${coindACParam}${data.ac_options.join(' ')}${_customParam}`, { maxBuffer: 1024 * 10000 // 10 mb }, function(error, stdout, stderr) { // console.log('stdout: ' + stdout); @@ -1335,7 +1406,7 @@ function herder(flock, data) { shepherd.writeLog(`exec error: ${error}`); } }); - } else { + /*} else { pm2.connect(true, function(err) { // start up pm2 god if (err) { console.error(err); @@ -1356,7 +1427,7 @@ function herder(flock, data) { 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`); @@ -1493,14 +1564,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); } @@ -1554,7 +1625,7 @@ function setConf(flock) { fs.readFile(DaemonConfPath, 'utf8', function(err, data) { if (err) { - shepherd.writeLog(`setconf error '${err}`); + shepherd.writeLog(`setconf error ${err}`); return console.log(err); } @@ -1777,7 +1848,7 @@ function formatBytes(bytes, decimals) { return '0 Bytes'; const k = 1000, - dm = decimals + 1 || 3, + dm = (decimals + 1) || 3, sizes = [ 'Bytes', 'KB', From 14f244452a73dfe7653e37c5c0d0846604fe9ed2 Mon Sep 17 00:00:00 2001 From: pbca26 Date: Tue, 4 Jul 2017 07:43:35 -0700 Subject: [PATCH 2/6] agama mode selector --- gui/index.html | 20 +++++++---- gui/init.js | 8 ++--- gui/loading.css | 78 +++++++++++++++++++++++++++++++++++++++++++ gui/loading.js | 82 ++++++++++++++++++++++++++++++---------------- main.js | 5 +-- routes/shepherd.js | 80 +++++++++++++++++++++++++++++++++----------- 6 files changed, 214 insertions(+), 59 deletions(-) diff --git a/gui/index.html b/gui/index.html index 5c6c9af..08937b4 100644 --- a/gui/index.html +++ b/gui/index.html @@ -13,14 +13,22 @@ - +
-
-
Starting Wallet. Please wait...
-
-
+ +
+ +
Choose Agama mode
+ +
-
diff --git a/gui/init.js b/gui/init.js index e09d705..b7f1414 100644 --- a/gui/init.js +++ b/gui/init.js @@ -1,21 +1,21 @@ $(document).ready(function() { const remote = require('electron').remote; var window = remote.getCurrentWindow(); + var appConf = remote.getCurrentWindow().appConfig; $('#pulse').jRoll({ radius: 100, animation: 'pulse' }); - GetAppConf(inititalWalletLoading); + inititalWalletLoading(); $('#loading_status_text').text('Starting Wallet. Please wait...'); - function inititalWalletLoading(appConf) { + function inititalWalletLoading() { // run iguana-less mode with no daemons startup if (appConf && appConf.iguanaLessMode) { - window.createWindow('open'); - window.hide(); + // do something } else { // run normal mode with 2 iguana instances started prior loading GUI if (appConf && !appConf.manualIguanaStart) { StartIguana(); diff --git a/gui/loading.css b/gui/loading.css index 74b3067..8a03008 100644 --- a/gui/loading.css +++ b/gui/loading.css @@ -25,4 +25,82 @@ 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 { + background-color: #ffa726; + border-color: #ffa726; +} + +.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; } \ No newline at end of file diff --git a/gui/loading.js b/gui/loading.js index 8a178bc..b2c1dd7 100644 --- a/gui/loading.js +++ b/gui/loading.js @@ -1,3 +1,53 @@ + function closeMainWindow() { + const remote = require('electron').remote; + var window = remote.getCurrentWindow(); + + window.createWindow('open'); + window.hide(); + } + + function normalStart() { + const remote = require('electron').remote; + var 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(); diff --git a/main.js b/main.js index f0d0e0d..5431d8a 100644 --- a/main.js +++ b/main.js @@ -196,13 +196,14 @@ function createLoadingWindow() { // initialise window loadingWindow = new BrowserWindow({ - width: appConfig.iguanaLessMode ? 1 : 500, - height: appConfig.iguanaLessMode ? 1 : 300, + width: 500, + height: 300, frame: false, icon: iguanaIcon }); 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/`); diff --git a/routes/shepherd.js b/routes/shepherd.js index 57262a9..d34a47b 100644 --- a/routes/shepherd.js +++ b/routes/shepherd.js @@ -827,26 +827,39 @@ shepherd.get('/InstantDEX/allcoins', function(req, res, next) { // 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 - } else { - let nativeCoindList = []; - - for (let key in coindInstanceRegistry) { - nativeCoindList.push(key === 'komodod' ? 'KMD' : key); - } + 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': [] }; - } - console.log(successObj); - - res.end(JSON.stringify(successObj)); + res.end(JSON.stringify(successObj)); + } }); /* @@ -857,15 +870,35 @@ 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 - const successObj = { - 'pubkey': 'nativeonly', - 'result': 'success', - 'handle': '', - 'status': Object.keys(coindInstanceRegistry).length ? 'unlocked' : 'locked', - 'duration': 2507830 - }; + let successObj; - res.end(JSON.stringify(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)); + } }); /* @@ -1374,7 +1407,8 @@ function herder(flock, data) { 'silent': '&', 'reindex': '-reindex', 'change': '-pubkey=', - 'datadir': '-datadir=' + 'datadir': '-datadir=', + 'rescan': '-rescan' }; let _customParam = ''; @@ -1404,6 +1438,14 @@ function herder(flock, data) { 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' + } + }); + } } }); /*} else { From c5a3fa576d1c9eef5af75c534d5386520e75313c Mon Sep 17 00:00:00 2001 From: pbca26 Date: Fri, 7 Jul 2017 10:52:10 +0300 Subject: [PATCH 3/6] new agama icon --- gui/agama-icon.svg | 43 +++++++++++++++++++++++++++++++++++++++++++ gui/index.html | 2 +- gui/loading.js | 4 ++-- 3 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 gui/agama-icon.svg diff --git a/gui/agama-icon.svg b/gui/agama-icon.svg new file mode 100644 index 0000000..4b9055c --- /dev/null +++ b/gui/agama-icon.svg @@ -0,0 +1,43 @@ + + + + background + + + + Layer 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/gui/index.html b/gui/index.html index 08937b4..14a6977 100644 --- a/gui/index.html +++ b/gui/index.html @@ -24,7 +24,7 @@
- +
Choose Agama mode
diff --git a/gui/loading.js b/gui/loading.js index b2c1dd7..445e078 100644 --- a/gui/loading.js +++ b/gui/loading.js @@ -1,6 +1,6 @@ function closeMainWindow() { const remote = require('electron').remote; - var window = remote.getCurrentWindow(); + const window = remote.getCurrentWindow(); window.createWindow('open'); window.hide(); @@ -8,7 +8,7 @@ function normalStart() { const remote = require('electron').remote; - var appConf = remote.getCurrentWindow().appConfig; + let appConf = remote.getCurrentWindow().appConfig; appConf.iguanaLessMode = false; // run iguana-less mode with no daemons startup From b4303fa7c1ff2a545caca5da0d0141f78166c377 Mon Sep 17 00:00:00 2001 From: pbca26 Date: Fri, 7 Jul 2017 11:17:41 -0700 Subject: [PATCH 4/6] removed corsproxy dependency --- gui/agama-icon-small.png | Bin 0 -> 7333 bytes main.js | 2 +- package.json | 1 - routes/shepherd.js | 136 +++++++++++++-------------------------- 4 files changed, 45 insertions(+), 94 deletions(-) create mode 100644 gui/agama-icon-small.png diff --git a/gui/agama-icon-small.png b/gui/agama-icon-small.png new file mode 100644 index 0000000000000000000000000000000000000000..739e2e0260be7ba93877cd7cad836f1196a6d393 GIT binary patch literal 7333 zcmV;W99rXvP)cb00004XF*Lt006O% z3;baP00009a7bBm000ic000ic0Tn1pfB*mh8FWQhbW?9;ba!ELWdLwtX>N2bZe?^J zG%heMF*ZbLuk`=`93n|XK~#8NySqg2FmM+v_%-CX<2lgSLjvUP12TNfjO zFn|KNb37JFG;10yx@JKzHa2J+U8fU7QL=95U;xEpwg4Q4PgeodWrzR;aKX_`M&rF= zA^Ugj`CaOmjm$r!GS~Gsc>X6{@(L=&U4qP!|7q2#%=K8)5pW@U~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=kl)|N~6b{lf0QG1G1qB%agGN?@Z6AF9D`bhWp@`2f>H{*yDHZ&o&nXKb-irKq! zL{b%JJeO!ZfcH`h|{pE6J{>&dG1V9F_qmSKeCqE9}nc5?nJ7Dk!1{#F@2 z_m$NuK@f!3UVoL{SnOOxnBmkN&fa2dG&ko+4`amA6^5LtG@St`DM7%9V1n+z!6SBK z$>sy7EygwpPl_c=nV>%Apcmta{Cc-)?8OA=2wD=6 zB=+8ex8<2jGxHW@IGK$*7WT5VccU%+Vn-)iYwQ05B6IawvYqZQ00000 LNkvXXu0mjf9dSOe literal 0 HcmV?d00001 diff --git a/main.js b/main.js index 5431d8a..4f45364 100644 --- a/main.js +++ b/main.js @@ -234,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 diff --git a/package.json b/package.json index 5ec5300..5b4e33c 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,6 @@ "dependencies": { "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", diff --git a/routes/shepherd.js b/routes/shepherd.js index d34a47b..5173f99 100644 --- a/routes/shepherd.js +++ b/routes/shepherd.js @@ -809,9 +809,9 @@ 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; } }); }); @@ -1360,9 +1360,9 @@ 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; } }); }); @@ -1402,74 +1402,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=', - 'datadir': '-datadir=', - 'rescan': '-rescan' - }; - 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}`; - } + 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}`; + } - 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('coindAC ' + coindACParam); - - coindInstanceRegistry[data.ac_name] = true; - exec(`${komododBin} ${coindACParam}${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}`); - - 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' - } - }); - } - } - }); - /*} 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('coindAC ' + coindACParam); + + 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`); @@ -1510,30 +1486,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) { From ab7e799dcd0cff3ca6d19ad3a091156a36cadaff Mon Sep 17 00:00:00 2001 From: pbca26 Date: Sat, 8 Jul 2017 03:17:21 -0700 Subject: [PATCH 5/6] cli stop eof --- routes/shepherd.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/routes/shepherd.js b/routes/shepherd.js index 5173f99..b160bcd 100644 --- a/routes/shepherd.js +++ b/routes/shepherd.js @@ -289,7 +289,8 @@ shepherd.quitKomodod = function() { console.log(`stdout: ${stdout}`); console.log(`stderr: ${stderr}`); - if (stdout.indexOf('stopping') > -1) { + if (stdout.indexOf('stopping') > -1 || + stdout.indexOf('EOF reached') > -1) { clearInterval(coindExitInterval[key]); } @@ -1368,6 +1369,7 @@ function herder(flock, data) { }); } + // 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'; @@ -1424,7 +1426,7 @@ function herder(flock, data) { const isChain = data.ac_name.match(/^[A-Z]*$/); const coindACParam = isChain ? ` -ac_name=${data.ac_name} ` : ''; - console.log('coindAC ' + coindACParam); + console.log('daemon param ' + data.ac_custom_param); coindInstanceRegistry[data.ac_name] = true; exec(`${komododBin} ${coindACParam}${data.ac_options.join(' ')}${_customParam}`, { @@ -1434,7 +1436,7 @@ function herder(flock, data) { shepherd.writeLog(`stderr: ${stderr}`); if (error !== null) { - console.log(`exec error: ${error}`) + console.log(`exec error: ${error}`); shepherd.writeLog(`exec error: ${error}`); if (error.toString().indexOf('using -reindex') > -1) { @@ -1474,7 +1476,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) { @@ -1615,7 +1617,7 @@ 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) { From bac87447bc26fd384d7f2a2d33436e40be13247a Mon Sep 17 00:00:00 2001 From: pbca26 Date: Sat, 8 Jul 2017 03:21:14 -0700 Subject: [PATCH 6/6] mode selector btn active style fix --- gui/loading.css | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/gui/loading.css b/gui/loading.css index 8a03008..f25764a 100644 --- a/gui/loading.css +++ b/gui/loading.css @@ -45,9 +45,11 @@ body.agamaMode { .btn-primary.focus, .btn-primary:focus, -.btn-primary:hover { - background-color: #ffa726; - border-color: #ffa726; +.btn-primary:hover, +.btn-primary:active, +.btn-primary.active { + background-color: #ffa726 !important; + border-color: #ffa726 !important; } .btn.active.focus,