Shepherd IPC updates
This commit is contained in:
parent
8630b2438a
commit
39a2260941
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 3.6 KiB |
|
@ -57,7 +57,7 @@ coin_select_options = `<optgroup label="Crytpo Coins">
|
|||
<option data-content="<img src='img/cryptologo/COQUI.png' width='50px;'/> COQUI (COQUI)" data-tokens="COQUI COQUI">COQUI</option>
|
||||
<option data-content="<img src='img/cryptologo/CRYPTO.png' width='50px'/> Crypto777 (CRYPTO)" data-tokens="Crypto777 CRYPTO">CRYPTO</option>
|
||||
<option data-content="<img src='img/cryptologo/DEX.png' width='50px;'/> InstantDEX (DEX)" data-tokens="InstantDEX DEX">DEX</option>
|
||||
<option data-content="<img src='img/cryptologo/HODL.png' width='50px'/> HODL (HODL)" data-tokens="HODL HODL">HODL</option>
|
||||
<option data-content="<img src='img/cryptologo/HODLC.png' width='50px'/> HODLC (HODLC)" data-tokens="HODLC HODLC">HODLC</option>
|
||||
<option data-content="<img src='img/cryptologo/JUMBLR.png' width='50px;'/> Jumblr (JUMBLR)" data-tokens="Jumblr JUMBLR">JUMBLR</option>
|
||||
<option data-content="<img src='img/cryptologo/KV.png' width='50px'/> KeyValue (KV)" data-tokens="KeyValue KV">KV</option>
|
||||
<option data-content="<img src='img/cryptologo/MESH.png' width='50px'/> SuperMesh (MESH)" data-tokens="SuperMesh MESH">MESH</option>
|
||||
|
|
|
@ -2,10 +2,13 @@ var CheckOrderbook_Interval = null;
|
|||
var CheckPortfolio_Interval = null;
|
||||
|
||||
$(document).ready(function() {
|
||||
var refresh_data = {"coin":" ", "status": "enable"};
|
||||
enable_disable_coin(refresh_data);
|
||||
get_myprices();
|
||||
CheckOrderbook_Interval = setInterval(CheckOrderBookFn,3000);
|
||||
var mmstatus = ShepherdIPCTest({"command":"mmstatus"});
|
||||
if (mmstatus !== 'closed') {
|
||||
var refresh_data = {"coin":" ", "status": "enable"};
|
||||
enable_disable_coin(refresh_data);
|
||||
get_myprices();
|
||||
CheckOrderbook_Interval = setInterval(CheckOrderBookFn,3000);
|
||||
}
|
||||
$('.set_goal_label_portfolio').html($('.sell_coin_p').selectpicker('val'));
|
||||
});
|
||||
|
||||
|
@ -1109,8 +1112,8 @@ function return_coin_name(coin) {
|
|||
case 'COQUI':
|
||||
coin_name = 'COQUI';
|
||||
break;
|
||||
case 'HODL':
|
||||
coin_name = 'HODL';
|
||||
case 'HODLC':
|
||||
coin_name = 'HODLC';
|
||||
break;
|
||||
case 'SHARK':
|
||||
coin_name = 'SHARK';
|
||||
|
|
|
@ -3,8 +3,14 @@
|
|||
const {ipcRenderer} = require('electron')
|
||||
|
||||
ShepherdIPCTest = function(data) {
|
||||
ipcRenderer.on('shepherd-reply', (event, arg) => {
|
||||
/*ipcRenderer.on('shepherd-reply', (event, arg) => {
|
||||
console.log(arg) // prints "pong"
|
||||
})
|
||||
ipcRenderer.send('shepherd-command', data)
|
||||
ipcRenderer.sendSync('shepherd-command', data)*/
|
||||
|
||||
// USING SYNCHRONOUS METHOD TO SEND AND RECIVE IPC COMMANDS/REPLIES
|
||||
//console.log(ipcRenderer.sendSync('shepherd-commandSync', 'ping')) // prints "pong"
|
||||
let shepherdreply = ipcRenderer.sendSync('shepherd-command', data);
|
||||
//console.log(shepherdreply);
|
||||
return shepherdreply;
|
||||
}
|
|
@ -27,14 +27,12 @@ var ps = require('ps-node'),
|
|||
if (os.platform() === 'darwin') {
|
||||
fixPath();
|
||||
var marketmakerBin = path.join(__dirname, '../assets/bin/osx/marketmaker'),
|
||||
marketmakerDir = `${process.env.HOME}/Library/Application Support/marketmaker`,
|
||||
marketmakerConfsDir = `${marketmakerDir}/confs`;
|
||||
marketmakerDir = `${process.env.HOME}/Library/Application Support/marketmaker`;
|
||||
}
|
||||
|
||||
if (os.platform() === 'linux') {
|
||||
var marketmakerBin = path.join(__dirname, '../assets/bin/linux64/marketmaker'),
|
||||
marketmakerDir = `${process.env.HOME}/.marketmaker`,
|
||||
marketmakerConfsDir = `${marketmakerDir}/confs`;
|
||||
marketmakerDir = `${process.env.HOME}/.marketmaker`;
|
||||
}
|
||||
|
||||
if (os.platform() === 'win32') {
|
||||
|
@ -42,36 +40,49 @@ if (os.platform() === 'win32') {
|
|||
marketmakerBin = path.normalize(marketmakerBin);
|
||||
marketmakerDir = `${process.env.APPDATA}/marketmaker`;
|
||||
marketmakerDir = path.normalize(marketmakerDir);
|
||||
marketmakerConfsDir = `${process.env.APPDATA}/marketmaker/confs`;
|
||||
marketmakerConfsDir = path.normalize(marketmakerConfsDir);
|
||||
marketmakerIcon = path.join(__dirname, '/assets/icons/agama_icons/agama_app_icon.ico'),
|
||||
marketmakerConfsDirSrc = path.normalize(marketmakerConfsDirSrc);
|
||||
marketmakerIcon = path.join(__dirname, '/assets/icons/agama_icons/agama_app_icon.ico');
|
||||
}
|
||||
|
||||
// DEFAULT COINS LIST FOR MARKETMAKER
|
||||
defaultCoinsListFile = path.join(__dirname, '../assets/coinslist.json');
|
||||
|
||||
|
||||
const {ipcMain} = require('electron');
|
||||
/*ipcMain.on('shepherd-commandSync', (event, arg) => {
|
||||
console.log(arg.command) // prints "ping"
|
||||
event.returnValue = 'pong'
|
||||
})*/
|
||||
|
||||
ipcMain.on('shepherd-command', (event, arg) => {
|
||||
console.log(arg) // prints "ping"
|
||||
switch (arg) {
|
||||
switch (arg.command) {
|
||||
case 'ping':
|
||||
event.sender.send('shepherd-reply', 'pong');
|
||||
//event.sender.send('shepherd-reply', 'pong');
|
||||
event.returnValue = 'pong'
|
||||
break;
|
||||
case 'login':
|
||||
console.log(marketmakerBin);
|
||||
console.log(marketmakerDir);
|
||||
console.log(marketmakerConfsDir);
|
||||
event.sender.send('shepherd-reply', 'Logged In');
|
||||
StartMarketMaker('');
|
||||
//event.sender.send('shepherd-reply', 'Logged In');
|
||||
event.returnValue = 'Logged In';
|
||||
//const _passphrase = 'scatter quote stumble confirm extra jacket lens abuse gesture soda rebel seed nature achieve hurt shoot farm middle venture fault mesh crew upset cotton';
|
||||
StartMarketMaker({"passphrase":arg.passphrase});
|
||||
break;
|
||||
case 'logout':
|
||||
killMarketmaker(true);
|
||||
event.returnValue = 'Logged Out';
|
||||
break;
|
||||
case 'mmstatus':
|
||||
portscanner.checkPortStatus(7779, '127.0.0.1', function(error, status) {
|
||||
console.log(status)
|
||||
//event.sender.send('shepherd-reply', status);
|
||||
event.returnValue = status;
|
||||
})
|
||||
break;
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
||||
// kill rogue marketmaker copies on start
|
||||
killMarketmaker = function(data) {
|
||||
if (data == true) {
|
||||
|
@ -113,44 +124,35 @@ killMarketmaker = function(data) {
|
|||
|
||||
|
||||
StartMarketMaker = function(data) {
|
||||
//console.log(data.passphrase);
|
||||
try {
|
||||
// check if marketmaker instance is already running
|
||||
portscanner.checkPortStatus(7779, '127.0.0.1', function(error, status) {
|
||||
// Status is 'open' if currently in use or 'closed' if available
|
||||
if (status === 'closed') {
|
||||
// start marketmaker via exec
|
||||
const _coinsList = [{"coin":"UIS","name":"unitus","rpcport":50604,"pubtype":68,"p2shtype":10,"wiftype":132,"txfee":1000000}];
|
||||
const _passphrase = 'scatter quote stumble confirm extra jacket lens abuse gesture soda rebel seed nature achieve hurt shoot farm middle venture fault mesh crew upset cotton';
|
||||
const _customParam = {
|
||||
'gui':'uglygui',
|
||||
'client':1,
|
||||
'userhome':`${process.env.HOME}`,
|
||||
'passphrase': _passphrase,
|
||||
'coins': _coinsList
|
||||
};
|
||||
|
||||
//console.log(JSON.stringify(_customParam))
|
||||
|
||||
console.log(`exec ${marketmakerBin} ${JSON.stringify(_customParam)}`);
|
||||
|
||||
exec(`${marketmakerBin} ${JSON.stringify(_customParam)}`, {
|
||||
maxBuffer: 1024 * 10000 // 10 mb
|
||||
}, function(error, stdout, stderr) {
|
||||
console.log(`stdout: ${stdout}`);
|
||||
console.log(`stderr: ${stderr}`);
|
||||
|
||||
if (error !== null) {
|
||||
console.log(`exec error: ${error}`);
|
||||
|
||||
/*if (error.toString().indexOf('using -reindex') > -1) {
|
||||
cache.io.emit('service', {
|
||||
'komodod': {
|
||||
'error': 'run -reindex'
|
||||
const _coinsListFile = marketmakerDir+'/coinslist.json'
|
||||
|
||||
fs.pathExists(_coinsListFile, (err, exists) => {
|
||||
if (exists === true) {
|
||||
console.log('file exist');
|
||||
data.coinslist = fs.readJsonSync(_coinsListFile, { throws: false });
|
||||
ExecMarketMaker(data);
|
||||
} else if (exists === false) {
|
||||
console.log('file doesn\'t exist');
|
||||
fs.copy(defaultCoinsListFile, _coinsListFile)
|
||||
.then(() => {
|
||||
console.log('file copied!')
|
||||
data.coinslist = fs.readJsonSync(_coinsListFile, { throws: false });
|
||||
ExecMarketMaker(data);
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(err)
|
||||
})
|
||||
}
|
||||
});
|
||||
}*/
|
||||
}
|
||||
});
|
||||
if (err) {
|
||||
console.log(err) // => null
|
||||
}
|
||||
})
|
||||
} else {
|
||||
console.log(`port ${_port} marketmaker is already in use`);
|
||||
}
|
||||
|
@ -161,3 +163,44 @@ StartMarketMaker = function(data) {
|
|||
}
|
||||
|
||||
|
||||
ExecMarketMaker = function(data) {
|
||||
//console.log(data);
|
||||
// start marketmaker via exec
|
||||
const _customParam = {
|
||||
'gui':'uglygui',
|
||||
'client':1,
|
||||
'userhome':`${process.env.HOME}`,
|
||||
'passphrase': data.passphrase,
|
||||
'coins': data.coinslist
|
||||
};
|
||||
|
||||
//console.log(JSON.stringify(_customParam))
|
||||
|
||||
//console.log(`exec ${marketmakerBin} ${JSON.stringify(_customParam)}`);
|
||||
|
||||
exec(`${marketmakerBin} '${JSON.stringify(_customParam)}'`, {
|
||||
cwd: marketmakerDir,
|
||||
maxBuffer: 1024 * 10000 // 10 mb
|
||||
}, function(error, stdout, stderr) {
|
||||
console.log(`stdout: ${stdout}`);
|
||||
console.log(`stderr: ${stderr}`);
|
||||
|
||||
if (error !== null) {
|
||||
console.log(`exec error: ${error}`);
|
||||
|
||||
/*if (error.toString().indexOf('using -reindex') > -1) {
|
||||
cache.io.emit('service', {
|
||||
'komodod': {
|
||||
'error': 'run'
|
||||
}
|
||||
});
|
||||
}*/
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
2
main.js
2
main.js
|
@ -103,7 +103,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);
|
||||
killMarketmaker(true);
|
||||
app.quit();
|
||||
//}
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue