From 2a7fc8713481e81de2669b566f83781fc39e0367 Mon Sep 17 00:00:00 2001 From: Jari Kolehmainen Date: Sun, 13 Dec 2020 19:11:37 +0200 Subject: [PATCH] Ensure only one app instance (#1742) * force only one app instance Signed-off-by: Jari Kolehmainen * fix Signed-off-by: Jari Kolehmainen --- src/main/index.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/index.ts b/src/main/index.ts index ea3c53f9b9..1c6b91c2c4 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -45,6 +45,16 @@ if (app.commandLine.getSwitchValue("proxy-server") !== "") { process.env.HTTPS_PROXY = app.commandLine.getSwitchValue("proxy-server"); } +const instanceLock = app.requestSingleInstanceLock(); + +if (!instanceLock) { + app.exit(); +} + +app.on("second-instance", () => { + windowManager?.ensureMainWindow(); +}); + app.on("ready", async () => { logger.info(`🚀 Starting Lens from "${workingDir}"`); await shellSync();