forked from Ejhfast/iris-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
42 lines (36 loc) · 1010 Bytes
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
const electron = require('electron');
const app = electron.app;
const BrowserWindow = electron.BrowserWindow;
app.on('ready', () => {
mainWindow = new BrowserWindow({
height: 800,
width: 1200
})
// load the local HTML file
let url = require('url').format({
protocol: 'file',
slashes: true,
pathname: require('path').join(__dirname, '/dist/index.html')
})
console.log(url)
mainWindow.loadURL(url)
})
pyProc = null;
const createPyProc = () => {
const path = require('path').join(__dirname, '');
console.log(pyProc);
if (pyProc === null){
pyProc = require('child_process').spawn('bash', [path+'/'+'start_backend.sh', path])
console.log(pyProc);
}
if (pyProc != null) {
console.log('child process success')
}
}
const exitPyProc = () => {
const path = require('path').join(__dirname, '');
killit = require('child_process').spawn('bash', [path+'/'+'stop_backend.sh'])
pyProc.kill()
}
app.on('ready', createPyProc)
app.on('will-quit', exitPyProc)