mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-02 20:43:36 +00:00
fix(windows): properly kill server process tree on app quit
On Windows, serverProcess.kill() doesn't reliably terminate Node.js child processes. This causes orphaned node processes to hold onto ports 3007/3008, preventing the app from starting on subsequent launches. Use taskkill with /f /t flags to force-kill the entire process tree on Windows, while keeping SIGTERM for macOS/Linux where it works correctly. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -595,9 +595,15 @@ app.on('window-all-closed', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
app.on('before-quit', () => {
|
app.on('before-quit', () => {
|
||||||
if (serverProcess) {
|
if (serverProcess && serverProcess.pid) {
|
||||||
console.log('[Electron] Stopping server...');
|
console.log('[Electron] Stopping server...');
|
||||||
serverProcess.kill();
|
if (process.platform === 'win32') {
|
||||||
|
// Windows: use taskkill with /t to kill entire process tree
|
||||||
|
// This prevents orphaned node processes when closing the app
|
||||||
|
spawn('taskkill', ['/f', '/t', '/pid', serverProcess.pid.toString()]);
|
||||||
|
} else {
|
||||||
|
serverProcess.kill('SIGTERM');
|
||||||
|
}
|
||||||
serverProcess = null;
|
serverProcess = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user