electron update, shepherd-ipc base started
This commit is contained in:
parent
c3c85958d4
commit
8971cd3a9e
|
@ -0,0 +1,52 @@
|
|||
const assetChainPorts = {
|
||||
'marketmaker': '7779',
|
||||
'komodod': '7771',
|
||||
'SUPERNET': '11341',
|
||||
'REVS': '10196',
|
||||
'WLC': '12167',
|
||||
'PANGEA': '10074',
|
||||
'DEX': '9503',
|
||||
'JUMBLR': '10789',
|
||||
'BET': '11222',
|
||||
'CRYPTO': '10420',
|
||||
'HODL': '8010',
|
||||
'SHARK': '14104',
|
||||
'BOTS': '10151',
|
||||
'MGW': '15524',
|
||||
'KV': '9747',
|
||||
'CEAL': '13097',
|
||||
'MESH': '8400',
|
||||
'USD': '13967',
|
||||
'CHF': '15312',
|
||||
'CAD': '8720',
|
||||
'BRL': '9914',
|
||||
'BGN': '9110',
|
||||
'AUD': '8045',
|
||||
'PLN': '13493',
|
||||
'PHP': '11181',
|
||||
'NZD': '10915',
|
||||
'NOK': '11588',
|
||||
'MYR': '10688',
|
||||
'MXN': '13970',
|
||||
'KRW': '14020',
|
||||
'JPY': '13145',
|
||||
'INR': '10536',
|
||||
'ILS': '14638',
|
||||
'IDR': '14459',
|
||||
'HKD': '15409',
|
||||
'HUF': '13699',
|
||||
'GBP': '11505',
|
||||
'EUR': '8065',
|
||||
'DKK': '13830',
|
||||
'CNY': '10384',
|
||||
'ZAR': '15160',
|
||||
'TRY': '13924',
|
||||
'THB': '11847',
|
||||
'SGD': '14475',
|
||||
'SEK': '11447',
|
||||
'RON': '8675',
|
||||
'RUB': '8199',
|
||||
'CZK': '9482'
|
||||
};
|
||||
|
||||
module.exports = assetChainPorts;
|
|
@ -0,0 +1,63 @@
|
|||
const electron = require('electron'),
|
||||
app = electron.app,
|
||||
BrowserWindow = electron.BrowserWindow,
|
||||
path = require('path'),
|
||||
url = require('url'),
|
||||
os = require('os'),
|
||||
osPlatform = os.platform(),
|
||||
fsnode = require('fs'),
|
||||
fs = require('fs-extra'),
|
||||
mkdirp = require('mkdirp'),
|
||||
exec = require('child_process').exec,
|
||||
spawn = require('child_process').spawn,
|
||||
portscanner = require('portscanner'),
|
||||
fixPath = require('fix-path'),
|
||||
numCPUs = require('os').cpus().length,
|
||||
ipc = require('electron').ipcMain;
|
||||
|
||||
Promise = require('bluebird');
|
||||
|
||||
var ps = require('ps-node'),
|
||||
shepherd = '',
|
||||
assetChainPorts = require('./ports.js');
|
||||
|
||||
|
||||
|
||||
// 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}`);
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
87
main.js
87
main.js
|
@ -15,6 +15,8 @@ const electron = require('electron'),
|
|||
mkdirp = require('mkdirp');
|
||||
|
||||
|
||||
var shepherd = require('./ipc/shepherd-ipc');
|
||||
|
||||
const appBasicInfo = {
|
||||
name: 'BarterDEX',
|
||||
version: '0.3.0-beta'
|
||||
|
@ -28,51 +30,38 @@ if (osPlatform === 'linux') {
|
|||
// console.log(process.env);
|
||||
}
|
||||
|
||||
|
||||
// kill rogue marketmaker copies on start
|
||||
//if (appConfig.killIguanaOnStart) {
|
||||
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}`);
|
||||
};
|
||||
});
|
||||
//}
|
||||
let closeAppAfterLoading = false;
|
||||
|
||||
// Keep a global reference of the window object, if you don't, the window will
|
||||
// be closed automatically when the JavaScript object is garbage collected.
|
||||
let mainWindow
|
||||
|
||||
function createWindow () {
|
||||
// Create the browser window.
|
||||
mainWindow = new BrowserWindow({width: 1280, height: 800})
|
||||
function createWindow (status) {
|
||||
require(path.join(__dirname, 'private/mainmenu'));
|
||||
|
||||
// initialise window
|
||||
mainWindow = new BrowserWindow({ // dirty hack to prevent main window flash on quit
|
||||
width: closeAppAfterLoading ? 1 : 1280,
|
||||
height: closeAppAfterLoading ? 1 : 800
|
||||
//icon: iguanaIcon
|
||||
});
|
||||
|
||||
const staticMenu = Menu.buildFromTemplate([ // if static
|
||||
{ role: 'copy' },
|
||||
{ type: 'separator' },
|
||||
{ role: 'selectall' },
|
||||
]);
|
||||
|
||||
const editMenu = Menu.buildFromTemplate([ // if editable
|
||||
{ role: 'undo' },
|
||||
{ role: 'redo' },
|
||||
{ type: 'separator' },
|
||||
{ role: 'cut' },
|
||||
{ role: 'copy' },
|
||||
{ role: 'paste' },
|
||||
{ type: 'separator' },
|
||||
{ role: 'selectall' },
|
||||
]);
|
||||
|
||||
// and load the index.html of the app.
|
||||
mainWindow.loadURL(url.format({
|
||||
|
@ -81,6 +70,16 @@ function createWindow () {
|
|||
slashes: true
|
||||
}))
|
||||
|
||||
mainWindow.webContents.on('context-menu', (e, params) => { // context-menu returns params
|
||||
const { selectionText, isEditable } = params; // params obj
|
||||
|
||||
if (isEditable) {
|
||||
editMenu.popup(mainWindow);
|
||||
} else if (selectionText && selectionText.trim() !== '') {
|
||||
staticMenu.popup(mainWindow);
|
||||
}
|
||||
});
|
||||
|
||||
// Open the DevTools.
|
||||
// mainWindow.webContents.openDevTools()
|
||||
|
||||
|
@ -91,6 +90,7 @@ function createWindow () {
|
|||
// when you should delete the corresponding element.
|
||||
mainWindow = null
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
// This method will be called when Electron has finished
|
||||
|
@ -102,9 +102,10 @@ app.on('ready', createWindow)
|
|||
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') {
|
||||
app.quit()
|
||||
}
|
||||
//if (process.platform !== 'darwin') {
|
||||
killMarketmaker(true);
|
||||
app.quit();
|
||||
//}
|
||||
})
|
||||
|
||||
app.on('activate', function () {
|
||||
|
|
|
@ -14,6 +14,16 @@
|
|||
"resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz",
|
||||
"integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo="
|
||||
},
|
||||
"bluebird": {
|
||||
"version": "3.5.0",
|
||||
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.0.tgz",
|
||||
"integrity": "sha1-eRQg1/VR7qKJdFOop3ZT+WYG1nw="
|
||||
},
|
||||
"connected-domain": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/connected-domain/-/connected-domain-1.0.0.tgz",
|
||||
"integrity": "sha1-v+dyOMdL5FOnnwy2BY3utPI1jpM="
|
||||
},
|
||||
"cross-spawn": {
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-4.0.2.tgz",
|
||||
|
@ -174,6 +184,14 @@
|
|||
"is-number-like": "1.0.8"
|
||||
}
|
||||
},
|
||||
"ps-node": {
|
||||
"version": "0.1.6",
|
||||
"resolved": "https://registry.npmjs.org/ps-node/-/ps-node-0.1.6.tgz",
|
||||
"integrity": "sha1-mvZ6mdex0BMuUaUDCZ04qNKs4sM=",
|
||||
"requires": {
|
||||
"table-parser": "0.1.3"
|
||||
}
|
||||
},
|
||||
"pseudomap": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz",
|
||||
|
@ -215,6 +233,14 @@
|
|||
"resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz",
|
||||
"integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8="
|
||||
},
|
||||
"table-parser": {
|
||||
"version": "0.1.3",
|
||||
"resolved": "https://registry.npmjs.org/table-parser/-/table-parser-0.1.3.tgz",
|
||||
"integrity": "sha1-BEHPzhallIFoTCfRtaZ/8VpDx7A=",
|
||||
"requires": {
|
||||
"connected-domain": "1.0.0"
|
||||
}
|
||||
},
|
||||
"universalify": {
|
||||
"version": "0.1.1",
|
||||
"resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.1.tgz",
|
||||
|
|
|
@ -25,9 +25,11 @@
|
|||
"electron": "^1.7.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"bluebird": "^3.5.0",
|
||||
"fix-path": "^2.1.0",
|
||||
"fs-extra": "^4.0.1",
|
||||
"mkdirp": "^0.5.1",
|
||||
"portscanner": "^2.1.1"
|
||||
"portscanner": "^2.1.1",
|
||||
"ps-node": "^0.1.6"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,209 @@
|
|||
const {Menu} = require('electron'),
|
||||
electron = require('electron'),
|
||||
app = electron.app,
|
||||
{shell} = require('electron');
|
||||
|
||||
const template = [
|
||||
{
|
||||
label: 'Edit',
|
||||
submenu: [
|
||||
{
|
||||
role: 'undo'
|
||||
},
|
||||
{
|
||||
role: 'redo'
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
role: 'cut'
|
||||
},
|
||||
{
|
||||
role: 'copy'
|
||||
},
|
||||
{
|
||||
role: 'paste'
|
||||
},
|
||||
{
|
||||
role: 'pasteandmatchstyle'
|
||||
},
|
||||
{
|
||||
role: 'delete'
|
||||
},
|
||||
{
|
||||
role: 'selectall'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
label: 'View',
|
||||
submenu: [
|
||||
{
|
||||
label: 'Reload',
|
||||
accelerator: 'CmdOrCtrl+R',
|
||||
click (item, focusedWindow) {
|
||||
if (focusedWindow)
|
||||
focusedWindow.reload();
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Toggle Developer Tools',
|
||||
accelerator: process.platform === 'darwin' ? 'Alt+Command+I' : 'Ctrl+Shift+I',
|
||||
click (item, focusedWindow) {
|
||||
if (focusedWindow)
|
||||
focusedWindow.webContents.toggleDevTools();
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
role: 'resetzoom'
|
||||
},
|
||||
{
|
||||
role: 'zoomin'
|
||||
},
|
||||
{
|
||||
role: 'zoomout'
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
role: 'togglefullscreen'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
role: 'window',
|
||||
submenu: [
|
||||
{
|
||||
role: 'minimize'
|
||||
},
|
||||
{
|
||||
role: 'close'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
role: 'help',
|
||||
label: 'Support',
|
||||
submenu: [
|
||||
{
|
||||
label: 'Supernet.org',
|
||||
click () {
|
||||
if (process.platform === 'linux') {
|
||||
require('child_process').exec('xdg-open http://support.supernet.org');
|
||||
} else {
|
||||
shell.openExternal('http://support.supernet.org');
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Slack',
|
||||
click () {
|
||||
if (process.platform === 'linux') {
|
||||
require('child_process').exec('xdg-open https://sprnt.slack.com/messages/support');
|
||||
} else {
|
||||
shell.openExternal('https://sprnt.slack.com/messages/support');
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Github',
|
||||
click () {
|
||||
if (process.platform === 'linux') {
|
||||
require('child_process').exec('xdg-open https://github.com/SuperNETorg/iguana/issues');
|
||||
} else {
|
||||
shell.openExternal('https://github.com/SuperNETorg/iguana/issues');
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
if (process.platform === 'darwin') {
|
||||
const name = app.getName();
|
||||
|
||||
template.unshift({
|
||||
label: name,
|
||||
submenu: [
|
||||
{
|
||||
role: 'about'
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
role: 'services',
|
||||
submenu: []
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
role: 'hide'
|
||||
},
|
||||
{
|
||||
role: 'hideothers'
|
||||
},
|
||||
{
|
||||
role: 'unhide'
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
label: 'Quit',
|
||||
accelerator: 'CmdOrCtrl+Q',
|
||||
role: 'close'
|
||||
}
|
||||
]
|
||||
});
|
||||
// Edit menu.
|
||||
template[1].submenu.push(
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
label: 'Speech',
|
||||
submenu: [
|
||||
{
|
||||
role: 'startspeaking'
|
||||
},
|
||||
{
|
||||
role: 'stopspeaking'
|
||||
}
|
||||
]
|
||||
}
|
||||
);
|
||||
// Window menu.
|
||||
template[3].submenu = [
|
||||
{
|
||||
label: 'Close',
|
||||
accelerator: 'CmdOrCtrl+W',
|
||||
role: 'close'
|
||||
},
|
||||
{
|
||||
label: 'Minimize',
|
||||
accelerator: 'CmdOrCtrl+M',
|
||||
role: 'minimize'
|
||||
},
|
||||
{
|
||||
label: 'Zoom',
|
||||
role: 'zoom'
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
label: 'Bring All to Front',
|
||||
role: 'front'
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
const menu = Menu.buildFromTemplate(template);
|
||||
Menu.setApplicationMenu(menu);
|
Loading…
Reference in New Issue