fix two clawx instances bug (#294)
This commit is contained in:
committed by
GitHub
Unverified
parent
fd58e721bd
commit
5ddb7d281d
@@ -37,6 +37,15 @@ import { ensureBuiltinSkillsInstalled } from '../utils/skill-config';
|
||||
// set `"disable-hardware-acceleration": false` in the app config (future).
|
||||
app.disableHardwareAcceleration();
|
||||
|
||||
// Prevent multiple instances of the app from running simultaneously.
|
||||
// Without this, two instances each spawn their own gateway process on the
|
||||
// same port, then each treats the other's gateway as "orphaned" and kills
|
||||
// it — creating an infinite kill/restart loop on Windows.
|
||||
const gotTheLock = app.requestSingleInstanceLock();
|
||||
if (!gotTheLock) {
|
||||
app.quit();
|
||||
}
|
||||
|
||||
// Global references
|
||||
let mainWindow: BrowserWindow | null = null;
|
||||
const gatewayManager = new GatewayManager();
|
||||
@@ -242,6 +251,15 @@ async function initialize(): Promise<void> {
|
||||
});
|
||||
}
|
||||
|
||||
// When a second instance is launched, focus the existing window instead.
|
||||
app.on('second-instance', () => {
|
||||
if (mainWindow) {
|
||||
if (mainWindow.isMinimized()) mainWindow.restore();
|
||||
mainWindow.show();
|
||||
mainWindow.focus();
|
||||
}
|
||||
});
|
||||
|
||||
// Application lifecycle
|
||||
app.whenReady().then(() => {
|
||||
initialize();
|
||||
|
||||
Reference in New Issue
Block a user