Commit 37911e4a authored by Sergei Zubov's avatar Sergei Zubov

Modify daemon exit

parent f7a1c0e0
const electron = require('electron');
import "isomorphic-fetch";
// Module to control application life.
const app = electron.app;
......@@ -86,16 +87,20 @@ app.on('ready', function () {
}
});
app.on('before-quit', function () {
closeDeStreamApi();
});
// Quit when all windows are closed.
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();
fetch('http://localhost:56864/api/node/shutdown', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
})
.then(response => app.quit())
.catch(error => setTimeout(() => app.quit(), 5000));
}
});
......@@ -107,23 +112,6 @@ app.on('activate', function () {
}
});
function closeDeStreamApi() {
// if (process.platform !== 'darwin' && !serve) {
if (process.platform !== 'darwin' && !serve) {
var http2 = require('http');
const options2 = {
hostname: 'localhost',
port: 56864,
path: '/api/node/shutdown',
method: 'POST'
};
const req = http2.request(options2, (res) => {});
req.write('');
req.end();
}
};
function startDeStreamApi() {
var destreamProcess;
const spawnDeStream = require('child_process').spawn;
......@@ -147,7 +135,6 @@ function startDeStreamApi() {
detached: false
});
}
destreamProcess.stdout.on('data', (data) => {
writeLog(`DeStream: ${data}`);
});
......
......@@ -58,6 +58,8 @@
"core-js": "2.5.3",
"electron-context-menu": "0.9.1",
"enhanced-resolve": "3.4.1",
"es6-promise": "^4.2.5",
"isomorphic-fetch": "^2.2.1",
"ngx-bootstrap": "2.0.0-beta.11",
"ngx-clipboard": "9.0.0",
"rxjs": "5.5.5",
......
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