From 2f5ea420811a09c0adc8a321d46904dcc064e633 Mon Sep 17 00:00:00 2001 From: pbca26 Date: Tue, 28 Mar 2017 21:05:53 +0300 Subject: [PATCH 1/3] added experimental iguana pkill --- main.js | 36 +++++++++++++++++++++++++----------- routes/shepherd.js | 3 ++- 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/main.js b/main.js index 9c8e35a..b69245e 100644 --- a/main.js +++ b/main.js @@ -25,7 +25,7 @@ var express = require('express'), Promise = require('bluebird'); app.setName('Agama'); -app.setVersion('0.1.6.1e-beta'); +app.setVersion('0.1.6.0e-beta'); if (os.platform() === 'linux') { process.env.ELECTRON_RUN_AS_NODE = true; @@ -37,6 +37,23 @@ var shepherd = require('./routes/shepherd'), guiapp = express(), appConfig = shepherd.loadLocalConfig(); // load app config +if (appConfig.killIguanaOnStart) { + exec('ps -p $(pidof iguana)', function(error, stdout, stderr) { + if (stdout.indexOf('iguana') > -1) { + console.log('found another iguana process(es)'); + exec('pkill iguana', function(error, stdout, stderr) { + console.log('pkill iguana is issued'); + if (error !== null) { + console.log('pkill iguana exec error: ' + error) + }; + }); + } + if (error !== null) { + console.log('ps -p $(pidof iguana) exec error: ' + error) + }; + }); +} + guiapp.use(function(req, res, next) { res.header('Access-Control-Allow-Origin', 'http://127.0.0.1:' + appConfig.iguanaAppPort); res.header('Access-Control-Allow-Headers', 'X-Requested-With'); @@ -217,11 +234,8 @@ function createLoadingWindow() { /* the user only tried to close the window */ closeAppAfterLoading = true; e.preventDefault(); - console.log('lwindow' + loadingWindow); - if (loadingWindow) - loadingWindow.hide(); } - }); + }); //ca333 todo - add os detector to use correct binary - so we can use the same bundle on ALL OS platforms /*if (os.platform() === 'win32') { @@ -250,9 +264,9 @@ function createWindow (status) { require(path.join(__dirname, 'private/mainmenu')); // initialise window - mainWindow = new BrowserWindow({ - width: 1280, - height: 800, + mainWindow = new BrowserWindow({ // dirty hack to prevent main window flash on quit + width: closeAppAfterLoading ? 1 : 1280, + height: closeAppAfterLoading ? 1 : 800, icon: iguanaIcon }); @@ -366,7 +380,7 @@ function createWindow (status) { return KillPm2(); }) .then(HideMainWindow) - .then(QuitApp); + .then(QuitApp); } // if window closed we kill iguana proc @@ -396,10 +410,10 @@ app.on('before-quit', function (event) { console.log('before-quit'); if (mainWindow === null && loadingWindow != null) { //mainWindow not intitialised and loadingWindow not dereferenced //loading window is still open - if (os.platform() === 'darwin') { + if (os.platform() === 'darwin' || os.platform() === 'linux') { + closeAppAfterLoading = true; let code = `$('#loading_status_text').html('Preparing to shutdown the wallet.
Please wait while all daemons are closed...')`; loadingWindow.webContents.executeJavaScript(code); - closeAppAfterLoading = true; } console.log('before-quit prevented'); event.preventDefault(); diff --git a/routes/shepherd.js b/routes/shepherd.js index 8201481..7b436bb 100644 --- a/routes/shepherd.js +++ b/routes/shepherd.js @@ -84,7 +84,8 @@ shepherd.appConfig = { "maxDescriptors": { "darwin": 90000, "linux": 1000000 - } + }, + "killIguanaOnStart": false }; shepherd.saveLocalAppConf = function(appSettings) { From 1fb401270f3c4d8716e6ebca2289d9008066ab8c Mon Sep 17 00:00:00 2001 From: pbca26 Date: Tue, 28 Mar 2017 21:18:34 +0200 Subject: [PATCH 2/3] iguana pkill osx --- main.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/main.js b/main.js index b69245e..6789d27 100644 --- a/main.js +++ b/main.js @@ -38,7 +38,14 @@ var shepherd = require('./routes/shepherd'), appConfig = shepherd.loadLocalConfig(); // load app config if (appConfig.killIguanaOnStart) { - exec('ps -p $(pidof iguana)', function(error, stdout, stderr) { + var iguanaGrep; + if (os.platform() === 'darwin') { + iguanaGrep = "ps -p $(ps -A | grep -m1 iguana | awk '{print $1}')"; + } + if (os.platform() === 'linux') { + iguanaGrep = 'ps -p $(pidof iguana)'; + } + exec(iguanaGrep, function(error, stdout, stderr) { if (stdout.indexOf('iguana') > -1) { console.log('found another iguana process(es)'); exec('pkill iguana', function(error, stdout, stderr) { From 3e80e1997492cb37c7be220dbaa168d8f4e736b2 Mon Sep 17 00:00:00 2001 From: pbca26 Date: Tue, 28 Mar 2017 21:23:46 +0300 Subject: [PATCH 3/3] fixed back app version change --- main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.js b/main.js index 6789d27..3e30a55 100644 --- a/main.js +++ b/main.js @@ -25,7 +25,7 @@ var express = require('express'), Promise = require('bluebird'); app.setName('Agama'); -app.setVersion('0.1.6.0e-beta'); +app.setVersion('0.1.6.1e-beta'); if (os.platform() === 'linux') { process.env.ELECTRON_RUN_AS_NODE = true;