Commit 55a2b35e authored by dev0tion's avatar dev0tion

Spawn two daemon processes on start

parent e9cc5ff7
...@@ -61,22 +61,10 @@ function createWindow() { ...@@ -61,22 +61,10 @@ function createWindow() {
// Emitted when the window is going to close. // Emitted when the window is going to close.
mainWindow.on('close', function () { mainWindow.on('close', function () {
if (process.platform !== 'darwin' && !serve) { closeBitcoinApi(),
var http = require('http'); closeStratisApi();
const options = { })
hostname: 'localhost', };
port: 5000,
path: '/api/node/shutdown',
method: 'POST'
};
const req = http.request(options, (res) => {});
req.write('');
req.end();
}
}
);
}
// This method will be called when Electron has finished // This method will be called when Electron has finished
// initialization and is ready to create browser windows. // initialization and is ready to create browser windows.
...@@ -86,7 +74,8 @@ app.on('ready', function () { ...@@ -86,7 +74,8 @@ app.on('ready', function () {
console.log("Breeze UI was started in development mode. This requires the user to be running the Breeze Daemon himself.") console.log("Breeze UI was started in development mode. This requires the user to be running the Breeze Daemon himself.")
} }
else { else {
startApi(); startBitcoinApi();
startStratisApi();
} }
createTray(); createTray();
createWindow(); createWindow();
...@@ -113,17 +102,73 @@ app.on('activate', function () { ...@@ -113,17 +102,73 @@ app.on('activate', function () {
} }
}); });
function startApi() { function closeBitcoinApi() {
var apiProcess; if (process.platform !== 'darwin' && !serve) {
const exec = require('child_process').exec; var http1 = require('http');
const options1 = {
hostname: 'localhost',
port: 5000,
path: '/api/node/shutdown',
method: 'POST'
};
const req = http1.request(options1, (res) => {});
req.write('');
req.end();
}
};
function closeStratisApi() {
if (process.platform !== 'darwin' && !serve) {
var http2 = require('http');
const options2 = {
hostname: 'localhost',
port: 5105,
path: '/api/node/shutdown',
method: 'POST'
};
const req = http2.request(options2, (res) => {});
req.write('');
req.end();
}
};
function startBitcoinApi() {
var bitcoinProcess;
const execBitcoin = require('child_process').exec;
//Start Breeze Bitcoin Daemon
let apiPath = path.join(__dirname, '".//assets//daemon//Breeze.Daemon"');
if (os.platform() === 'win32') {
apiPath = path.join(__dirname, '".\\assets\\daemon\\Breeze.Daemon.exe"');
}
bitcoinProcess = execBitcoin('"' + apiPath + '" light -testnet', {
detached: true
}, (error, stdout, stderr) => {
if (error) {
writeLogError(`exec error: ${error}`);
return;
}
if (serve) {
writeLog(`stdout: ${stdout}`);
writeLog(`stderr: ${stderr}`);
}
});
}
function startStratisApi() {
var stratisProcess;
const execStratis = require('child_process').exec;
//Start Breeze Daemon //Start Breeze Stratis Daemon
let apiPath = path.join(__dirname, '".//assets//daemon//Breeze.Daemon"'); let apiPath = path.join(__dirname, '".//assets//daemon//Breeze.Daemon"');
if (os.platform() === 'win32') { if (os.platform() === 'win32') {
apiPath = path.join(__dirname, '".\\assets\\daemon\\Breeze.Daemon.exe"'); apiPath = path.join(__dirname, '".\\assets\\daemon\\Breeze.Daemon.exe"');
} }
apiProcess = exec('"' + apiPath + '" light -testnet', { stratisProcess = execStratis('"' + apiPath + '" stratis light -testnet', {
detached: true detached: true
}, (error, stdout, stderr) => { }, (error, stdout, stderr) => {
if (error) { if (error) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment