From b225789745058ece3ff9408e74379c8af7ab10dc Mon Sep 17 00:00:00 2001 From: pbca26 Date: Tue, 11 Apr 2017 18:15:18 +0300 Subject: [PATCH 1/5] v2 wallet dev only switch --- routes/shepherd.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/routes/shepherd.js b/routes/shepherd.js index f494ca9..992e2c0 100644 --- a/routes/shepherd.js +++ b/routes/shepherd.js @@ -90,7 +90,8 @@ shepherd.appConfig = { "linux": 1000000 }, "killIguanaOnStart": true, - "dev": false + "dev": false, + "v2": false }; shepherd.saveLocalAppConf = function(appSettings) { From dd7ce651c198a7665fce95c6c8e77a30de79fd02 Mon Sep 17 00:00:00 2001 From: pbca26 Date: Tue, 11 Apr 2017 18:21:11 +0300 Subject: [PATCH 2/5] v2 dev only switch #2 --- main.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/main.js b/main.js index ef3113e..666b242 100644 --- a/main.js +++ b/main.js @@ -70,7 +70,7 @@ if (appConfig.killIguanaOnStart) { } guiapp.use(function(req, res, next) { - res.header('Access-Control-Allow-Origin', appConfig.dev ? '*' : 'http://127.0.0.1:' + appConfig.iguanaAppPort); + res.header('Access-Control-Allow-Origin', appConfig.dev ? '*' : 'http://127.0.0.1:3000'); res.header('Access-Control-Allow-Headers', 'X-Requested-With'); res.header('Access-Control-Allow-Credentials', 'true'); res.header('Access-Control-Allow-Headers', 'Content-Type'); @@ -306,7 +306,11 @@ function createWindow (status) { // load our index.html (i.e. easyDEX GUI) if (appConfig.edexGuiOnly) { - mainWindow.loadURL('http://' + appConfig.host + ':' + appConfig.iguanaAppPort + '/gui/EasyDEX-GUI/'); + if (appConfig.v2) { + mainWindow.loadURL('http://' + appConfig.host + ':' + appConfig.iguanaAppPort + '/gui/EasyDEX-GUI/react/build'); + } else { + mainWindow.loadURL('http://' + appConfig.host + ':' + appConfig.iguanaAppPort + '/gui/EasyDEX-GUI/'); + } } else { mainWindow.loadURL('http://' + appConfig.host + ':' + appConfig.iguanaAppPort + '/gui/main.html'); } From 16107a4644fd5b9d2c3a5e0a5f558b544999eb47 Mon Sep 17 00:00:00 2001 From: pbca26 Date: Mon, 24 Apr 2017 11:09:51 +0300 Subject: [PATCH 3/5] komodod quit via exec --- main.js | 4 +++- routes/shepherd.js | 58 ++++++++++++++++++++++++++++++++-------------- 2 files changed, 44 insertions(+), 18 deletions(-) diff --git a/main.js b/main.js index 666b242..58d4272 100644 --- a/main.js +++ b/main.js @@ -121,7 +121,7 @@ server.listen(appConfig.iguanaAppPort, function() { console.log('guiapp and sockets.io are listening on port ' + appConfig.iguanaAppPort + '!'); }); -io.set('origins', 'http://127.0.0.1:' + appConfig.iguanaAppPort); // set origin +io.set('origins', appConfig.dev ? 'http://127.0.0.1:3000' : 'http://127.0.0.1:' + appConfig.iguanaAppPort); // set origin io.on('connection', function(client) { console.log('EDEX GUI is connected...'); @@ -333,6 +333,8 @@ function createWindow (status) { return new Promise(function(resolve, reject) { console.log('Closing Main Window...'); + shepherd.quitKomodod(); + pm2.connect(true, function(err) { console.log('connecting to pm2...'); diff --git a/routes/shepherd.js b/routes/shepherd.js index 992e2c0..b323de9 100644 --- a/routes/shepherd.js +++ b/routes/shepherd.js @@ -94,6 +94,18 @@ shepherd.appConfig = { "v2": false }; +shepherd.quitKomodod = function() { + // exit komodod gracefully + console.log('exec ' + komodocliBin + ' stop'); + exec(komodocliBin + ' stop', function(error, stdout, stderr) { + console.log('stdout: ' + stdout) + console.log('stderr: ' + stderr) + if (error !== null) { + console.log('exec error: ' + error) + } + }); +} + shepherd.saveLocalAppConf = function(appSettings) { var appConfFileName = iguanaDir + '/config.json'; @@ -738,24 +750,36 @@ function herder(flock, data) { 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); - 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 - }, function(err, apps) { - pm2.disconnect(); // Disconnect from PM2 - if (err) - throw err; + // start komodod via exec + if (data.ac_name === 'komodod') { + console.log('exec' + komododBin + ' -' + data.ac_options.join(' ')); + exec(komododBin + ' -' + data.ac_options.join(' '), function(error, stdout, stderr) { + console.log('stdout: ' + stdout) + console.log('stderr: ' + stderr) + if (error !== null) { + console.log('exec error: ' + error) + } }); - }); + } else { + 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 + }, function(err, apps) { + pm2.disconnect(); // Disconnect from PM2 + if (err) + throw err; + }); + }); + } } else { console.log('port ' + _port + ' (' + data.ac_name + ') is already in use'); } From f4ae5f0130eabde8f77e0bf56946bb5ba943dfcb Mon Sep 17 00:00:00 2001 From: Petr Balashov Date: Mon, 24 Apr 2017 02:02:04 -0700 Subject: [PATCH 4/5] bugfix --- routes/shepherd.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/routes/shepherd.js b/routes/shepherd.js index b323de9..61417f3 100644 --- a/routes/shepherd.js +++ b/routes/shepherd.js @@ -752,8 +752,8 @@ function herder(flock, data) { if (status === 'closed') { // start komodod via exec if (data.ac_name === 'komodod') { - console.log('exec' + komododBin + ' -' + data.ac_options.join(' ')); - exec(komododBin + ' -' + data.ac_options.join(' '), function(error, stdout, stderr) { + console.log('exec' + komododBin + ' ' + data.ac_options.join(' ')); + exec(komododBin + ' ' + data.ac_options.join(' '), function(error, stdout, stderr) { console.log('stdout: ' + stdout) console.log('stderr: ' + stderr) if (error !== null) { From ba39710d60d2a9a749476e1131bd15d1b2e02343 Mon Sep 17 00:00:00 2001 From: Petr Balashov Date: Mon, 24 Apr 2017 02:44:52 -0700 Subject: [PATCH 5/5] komodod quit interval --- main.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/main.js b/main.js index 58d4272..68b30d7 100644 --- a/main.js +++ b/main.js @@ -334,6 +334,10 @@ function createWindow (status) { console.log('Closing Main Window...'); 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...');