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