From a2df2cd8e07b9cb4acc3972753a64dad4adbf6ae Mon Sep 17 00:00:00 2001 From: pbca26 Date: Thu, 31 Aug 2017 23:59:30 +0300 Subject: [PATCH] komodod quit timeout fix --- main.js | 11 +++++++---- routes/shepherd.js | 18 ++++++++++++++++-- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/main.js b/main.js index 224ac03..c3fb2e5 100644 --- a/main.js +++ b/main.js @@ -71,10 +71,10 @@ shepherd.writeLog(`os_release: ${os.release()}`); shepherd.writeLog(`os_type: ${os.type()}`); var appConfig = shepherd.loadLocalConfig(); // load app config -appConfig['daemonTest'] = false; // shadow setting +appConfig['daemonOutput'] = false; // shadow setting let __defaultAppSettings = require('./routes/appConfig.js').config; -__defaultAppSettings['daemonTest'] = false; // shadow setting +__defaultAppSettings['daemonOutput'] = false; // shadow setting const _defaultAppSettings = __defaultAppSettings; shepherd.writeLog(`app started in ${(appConfig.dev ? 'dev mode' : ' user mode')}`); @@ -288,7 +288,7 @@ function createAppSettingsWindow() { // initialise window appSettingsWindow = new BrowserWindow({ // dirty hack to prevent main window flash on quit width: 750, - height: 800, + height: 820, frame: false, icon: iguanaIcon, show: false, @@ -302,6 +302,8 @@ function createAppSettingsWindow() { appSettingsWindow.testLocation = shepherd.testLocation; appSettingsWindow.setDefaultAppSettings = setDefaultAppSettings; appSettingsWindow.updateAppSettings = updateAppSettings; + appSettingsWindow.testBins = shepherd.testBins; + appSettingsWindow.zcashParamsExist = _zcashParamsExist; appSettingsWindow.loadURL(`http://${appConfig.host}:${appConfig.agamaPort}/gui/app-settings.html`); appSettingsWindow.webContents.on('did-finish-load', function() { @@ -407,7 +409,7 @@ function createWindow(status) { shepherd.writeLog('exiting app...'); shepherd.dumpCacheBeforeExit(); - shepherd.quitKomodod(); + shepherd.quitKomodod(1000); pm2.connect(true, function(err) { console.log('connecting to pm2...'); @@ -526,6 +528,7 @@ app.on('window-all-closed', function() { // Calling event.preventDefault() will prevent the default behaviour, which is terminating the application. app.on('before-quit', function(event) { console.log('before-quit'); + shepherd.killRogueProcess('iguana'); // kill any rogue iguana core instances if (!forceQuitApp && mainWindow === null && loadingWindow != null) { // mainWindow not intitialised and loadingWindow not dereferenced // loading window is still open console.log('before-quit prevented'); diff --git a/routes/shepherd.js b/routes/shepherd.js index 155398c..33e6998 100644 --- a/routes/shepherd.js +++ b/routes/shepherd.js @@ -477,6 +477,7 @@ shepherd.zcashParamsExist = function() { provingKeySize: false, verifyingKey: _fs.existsSync(`${zcashParamsDir}/sprout-verifying.key`), verifyingKeySize: false, + errors: false, }; if (_checkList.rootDir && @@ -492,12 +493,20 @@ shepherd.zcashParamsExist = function() { if (_verifyingKeySize.size === 1449) { _checkList.verifyingKeySize = true; } + console.log('zcashparams exist'); } else { console.log('zcashparams doesnt exist'); } - console.log(JSON.stringify(_checkList, null, '\t')); + if (!_checkList.rootDir || + !_checkList.provingKey || + !_checkList.verifyingKey || + !_checkList.provingKeySize || + !_checkList.verifyingKeySize) { + _checkList.errors = true; + } + return _checkList; } @@ -1216,7 +1225,7 @@ shepherd.quitKomodod = function(timeout = 100) { for (let key in coindInstanceRegistry) { const chain = key !== 'komodod' ? key : null; - coindExitInterval[key] = setInterval(function() { + function execCliStop() { let _arg = []; if (chain) { _arg.push(`-ac_name=${chain}`); @@ -1240,6 +1249,11 @@ shepherd.quitKomodod = function(timeout = 100) { } shepherd.killRogueProcess('komodo-cli'); }); + } + + execCliStop(); + coindExitInterval[key] = setInterval(function() { + execCliStop(); }, timeout); } }