kill mm on quit
This commit is contained in:
parent
d471c6a460
commit
08a4e4cffc
|
@ -0,0 +1,54 @@
|
|||
const os = require('os');
|
||||
const exec = require('child_process').exec;
|
||||
const electron = require('electron');
|
||||
const app = electron.app;
|
||||
|
||||
// kill rogue marketmaker copies on start
|
||||
killMarketmaker = function(data, quit) {
|
||||
if (data == true) {
|
||||
let marketmakerGrep;
|
||||
const osPlatform = os.platform();
|
||||
|
||||
switch (osPlatform) {
|
||||
case 'darwin':
|
||||
marketmakerGrep = "ps -p $(ps -A | grep -m1 marketmaker | awk '{print $1}') | grep -i marketmaker";
|
||||
break;
|
||||
case 'linux':
|
||||
marketmakerGrep = 'ps -p $(pidof marketmaker) | grep -i marketmaker';
|
||||
break;
|
||||
case 'win32':
|
||||
marketmakerGrep = 'tasklist';
|
||||
break;
|
||||
}
|
||||
|
||||
exec(marketmakerGrep, function(error, stdout, stderr) {
|
||||
if (stdout.indexOf('marketmaker') > -1) {
|
||||
const pkillCmd = osPlatform === 'win32' ? 'taskkill /f /im marketmaker.exe' : 'pkill -15 marketmaker';
|
||||
|
||||
console.log('found another marketmaker process(es)');
|
||||
|
||||
exec(pkillCmd, function(error, stdout, stderr) {
|
||||
console.log(`${pkillCmd} is issued`);
|
||||
|
||||
if (quit) {
|
||||
app.quit();
|
||||
}
|
||||
|
||||
if (error !== null) {
|
||||
console.log(`${pkillCmd} exec error: ${error}`);
|
||||
};
|
||||
});
|
||||
} else {
|
||||
if (quit) {
|
||||
app.quit();
|
||||
}
|
||||
}
|
||||
|
||||
if (error !== null) {
|
||||
console.log(`${marketmakerGrep} exec error: ${error}`);
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = killMarketmaker;
|
|
@ -21,6 +21,7 @@ var ps = require('ps-node'),
|
|||
shepherd = '',
|
||||
assetChainPorts = require('./ports.js');
|
||||
|
||||
const killmm = require('./killmm');
|
||||
|
||||
// SETTING OS DIR TO RUN MARKETMAKER FROM
|
||||
// SETTING APP ICON FOR LINUX AND WINDOWS
|
||||
|
@ -69,7 +70,7 @@ ipcMain.on('shepherd-command', (event, arg) => {
|
|||
StartMarketMaker({"passphrase":arg.passphrase});
|
||||
break;
|
||||
case 'logout':
|
||||
killMarketmaker(true);
|
||||
killmm(true);
|
||||
event.returnValue = 'Logged Out';
|
||||
break;
|
||||
case 'mmstatus':
|
||||
|
@ -82,47 +83,6 @@ ipcMain.on('shepherd-command', (event, arg) => {
|
|||
}
|
||||
})
|
||||
|
||||
|
||||
// kill rogue marketmaker copies on start
|
||||
killMarketmaker = function(data) {
|
||||
if (data == true) {
|
||||
let marketmakerGrep;
|
||||
|
||||
switch (osPlatform) {
|
||||
case 'darwin':
|
||||
marketmakerGrep = "ps -p $(ps -A | grep -m1 marketmaker | awk '{print $1}') | grep -i marketmaker";
|
||||
break;
|
||||
case 'linux':
|
||||
marketmakerGrep = 'ps -p $(pidof marketmaker) | grep -i marketmaker';
|
||||
break;
|
||||
case 'win32':
|
||||
marketmakerGrep = 'tasklist';
|
||||
break;
|
||||
}
|
||||
|
||||
exec(marketmakerGrep, function(error, stdout, stderr) {
|
||||
if (stdout.indexOf('marketmaker') > -1) {
|
||||
const pkillCmd = osPlatform === 'win32' ? 'taskkill /f /im marketmaker.exe' : 'pkill -15 marketmaker';
|
||||
|
||||
console.log('found another marketmaker process(es)');
|
||||
|
||||
exec(pkillCmd, function(error, stdout, stderr) {
|
||||
console.log(`${pkillCmd} is issued`);
|
||||
|
||||
if (error !== null) {
|
||||
console.log(`${pkillCmd} exec error: ${error}`);
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
if (error !== null) {
|
||||
console.log(`${marketmakerGrep} exec error: ${error}`);
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
StartMarketMaker = function(data) {
|
||||
//console.log(data.passphrase);
|
||||
try {
|
||||
|
@ -131,7 +91,7 @@ StartMarketMaker = function(data) {
|
|||
// Status is 'open' if currently in use or 'closed' if available
|
||||
if (status === 'closed') {
|
||||
const _coinsListFile = marketmakerDir+'/coinslist.json'
|
||||
|
||||
|
||||
fs.pathExists(_coinsListFile, (err, exists) => {
|
||||
if (exists === true) {
|
||||
console.log('file exist');
|
||||
|
|
8
main.js
8
main.js
|
@ -17,6 +17,8 @@ const electron = require('electron'),
|
|||
|
||||
var shepherd = require('./ipc/shepherd-ipc');
|
||||
|
||||
const killmm = require('./ipc/killmm');
|
||||
|
||||
const appBasicInfo = {
|
||||
name: 'BarterDEX-Simple',
|
||||
version: '0.5.0-beta'
|
||||
|
@ -91,8 +93,9 @@ function createWindow (status) {
|
|||
// in an array if your app supports multi windows, this is the time
|
||||
// when you should delete the corresponding element.
|
||||
mainWindow = null
|
||||
killmm(true, true);
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
|
||||
// This method will be called when Electron has finished
|
||||
|
@ -105,8 +108,7 @@ app.on('window-all-closed', function () {
|
|||
// On OS X it is common for applications and their menu bar
|
||||
// to stay active until the user quits explicitly with Cmd + Q
|
||||
//if (process.platform !== 'darwin') {
|
||||
killMarketmaker(true);
|
||||
app.quit();
|
||||
killmm(true, true);
|
||||
//}
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in New Issue