Ensure process is killed on electron close

This commit is contained in:
Tzahi12345
2023-04-19 02:07:18 -04:00
parent 26de55fe86
commit 2098cc542c

View File

@@ -4,6 +4,7 @@ const { spawn } = require('child_process');
let win; let win;
let splashWindow; let splashWindow;
let serverProcess;
function createSplashWindow() { function createSplashWindow() {
splashWindow = new BrowserWindow({ splashWindow = new BrowserWindow({
@@ -44,7 +45,7 @@ function createMainWindow() {
} }
function createWindow() { function createWindow() {
const serverProcess = spawn('node', [path.join(__dirname, 'app.js')]); //, {cwd: 'backend'}); serverProcess = spawn('node', [path.join(__dirname, 'app.js')]);
createMainWindow(); createMainWindow();
createSplashWindow(); createSplashWindow();
@@ -77,6 +78,10 @@ app.on('window-all-closed', () => {
if (process.platform !== 'darwin') { if (process.platform !== 'darwin') {
app.quit(); app.quit();
} }
if (serverProcess) {
serverProcess.stdin.pause();
serverProcess.kill();
}
}); });
// initialize the app's main window // initialize the app's main window