From f94a74ab06382c376bb5a48b8905fb878f969ce4 Mon Sep 17 00:00:00 2001 From: pbca26 Date: Fri, 15 Sep 2017 02:07:17 +0300 Subject: [PATCH 1/2] hide exp settings --- main.js | 2 +- routes/shepherd.js | 39 ++++++++++++++++++++------------------- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/main.js b/main.js index c9923c3..f9acdd7 100644 --- a/main.js +++ b/main.js @@ -289,7 +289,7 @@ function createAppSettingsWindow() { // initialise window appSettingsWindow = new BrowserWindow({ // dirty hack to prevent main window flash on quit width: 750, - height: 820, + height: !appConfig.experimentalFeatures ? 570 : 700, frame: false, icon: iguanaIcon, show: false, diff --git a/routes/shepherd.js b/routes/shepherd.js index f08c6e6..2bac43c 100644 --- a/routes/shepherd.js +++ b/routes/shepherd.js @@ -129,7 +129,6 @@ shepherd.startKMDNative = function(selection, isManual) { '-daemon=0', '-addnode=78.47.196.146', ], - 'manualStart': isManual, }; const options = { @@ -2386,7 +2385,7 @@ shepherd.post('/herd', function(req, res) { shepherd.log(req.body); if (req.body.options && - !req.body.options.manualStart) { + !shepherd.kmdMainPassiveMode) { function testCoindPort(skipError) { if (!lockDownAddCoin) { const _port = assetChainPorts[req.body.options.ac_name]; @@ -2836,24 +2835,26 @@ function herder(flock, data) { shepherd.writeLog(`selected data: ${data}`); // truncate debug.log - try { - const _confFileAccess = _fs.accessSync(kmdDebugLogLocation, fs.R_OK | fs.W_OK); + if (!shepherd.kmdMainPassiveMode) { + try { + const _confFileAccess = _fs.accessSync(kmdDebugLogLocation, fs.R_OK | fs.W_OK); - if (_confFileAccess) { - shepherd.log(`error accessing ${kmdDebugLogLocation}`); - shepherd.writeLog(`error accessing ${kmdDebugLogLocation}`); - } else { - try { - fs.unlink(kmdDebugLogLocation); - shepherd.log(`truncate ${kmdDebugLogLocation}`); - shepherd.writeLog(`truncate ${kmdDebugLogLocation}`); - } catch (e) { - shepherd.log('cant unlink debug.log'); + if (_confFileAccess) { + shepherd.log(`error accessing ${kmdDebugLogLocation}`); + shepherd.writeLog(`error accessing ${kmdDebugLogLocation}`); + } else { + try { + fs.unlink(kmdDebugLogLocation); + shepherd.log(`truncate ${kmdDebugLogLocation}`); + shepherd.writeLog(`truncate ${kmdDebugLogLocation}`); + } catch (e) { + shepherd.log('cant unlink debug.log'); + } } + } catch(e) { + shepherd.log(`komodod debug.log access err: ${e}`); + shepherd.writeLog(`komodod debug.log access err: ${e}`); } - } catch(e) { - shepherd.log(`komodod debug.log access err: ${e}`); - shepherd.writeLog(`komodod debug.log access err: ${e}`); } // get komodod instance port @@ -2894,7 +2895,7 @@ function herder(flock, data) { shepherd.log(`daemon param ${data.ac_custom_param}`); coindInstanceRegistry[data.ac_name] = true; - if (!data.manualStart) { + if (!shepherd.kmdMainPassiveMode) { let _arg = `${coindACParam}${data.ac_options.join(' ')}${_customParam}`; _arg = _arg.trim().split(' '); execFile(`${komododBin}`, _arg, { @@ -2918,7 +2919,7 @@ function herder(flock, data) { }); } } else { - if (data.manualStart) { + if (shepherd.kmdMainPassiveMode) { coindInstanceRegistry[data.ac_name] = true; } shepherd.log(`port ${_port} (${data.ac_name}) is already in use`); From f7dfb4b3d09b6c07bbe467fe114a6645c33cbb69 Mon Sep 17 00:00:00 2001 From: pbca26 Date: Fri, 15 Sep 2017 19:06:13 +0300 Subject: [PATCH 2/2] silent errors; remove conf readonly file mode --- main.js | 9 +++++++++ routes/shepherd.js | 10 +++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/main.js b/main.js index f9acdd7..9011f3a 100644 --- a/main.js +++ b/main.js @@ -116,6 +116,15 @@ process.once('loaded', () => { } }); +// silent errors +if (!appConfig.debug || + !appConfig.dev) { + process.on('uncaughtException', (err) => { + shepherd.log(`${(new Date).toUTCString()} uncaughtException: ${err.message}`); + shepherd.log(err.stack); + }); +} + guiapp.use(bodyParser.json({ limit: '50mb' })); // support json encoded bodies guiapp.use(bodyParser.urlencoded({ limit: '50mb', diff --git a/routes/shepherd.js b/routes/shepherd.js index 2bac43c..dcea7fb 100644 --- a/routes/shepherd.js +++ b/routes/shepherd.js @@ -516,7 +516,7 @@ shepherd.testBins = function(daemonName) { _fs.access(`${iguanaTestDir}/${daemonName}Test.log`, fs.constants.R_OK, function(err) { if (!err) { try { - _fs.unlink(`${iguanaTestDir}/${daemonName}Test.log`); + _fs.unlinkSync(`${iguanaTestDir}/${daemonName}Test.log`); } catch (e) {} } else { shepherd.log(`path ${iguanaTestDir}/${daemonName}Test.log doesnt exist`); @@ -1368,7 +1368,7 @@ shepherd.updateAgama = function() { status: 'done', }, }); - fs.unlink(`${rootLocation}patch.zip`); + fs.unlinkSync(`${rootLocation}patch.zip`); } else { cache.io.emit('patch', { msg: { @@ -2844,7 +2844,7 @@ function herder(flock, data) { shepherd.writeLog(`error accessing ${kmdDebugLogLocation}`); } else { try { - fs.unlink(kmdDebugLogLocation); + fs.unlinkSync(kmdDebugLogLocation); shepherd.log(`truncate ${kmdDebugLogLocation}`); shepherd.writeLog(`truncate ${kmdDebugLogLocation}`); } catch (e) { @@ -3309,8 +3309,8 @@ function setConf(flock) { return FixFilePermissions(); }) .then(RemoveLines) - .then(CheckConf) - .then(MakeConfReadOnly); + .then(CheckConf); + // .then(MakeConfReadOnly); } function getConf(flock) {