diff --git a/index.js b/index.js index 96303060..a22e2bf1 100644 --- a/index.js +++ b/index.js @@ -666,6 +666,10 @@ if (isAutoLaunch) { app.quit(); } }); + app.on("quit", () => { + unlinkLALock(); + }); + app.on('ready', () => { clearLock(); appendLock(); @@ -693,13 +697,15 @@ if (isAutoLaunch) { setupExpress(); launchApp(); - // add agent - if (!devMode) { - const spawn = require('child_process').spawn; - spawn(process.execPath, ['--autostart'], { - stdio: 'ignore', - detached: true - }).unref(); + if (!fs.existsSync(lockAutoLaunchFile)) { + // add agent + if (!devMode) { + const spawn = require('child_process').spawn; + spawn(process.execPath, ['--autostart'], { + stdio: 'ignore', + detached: true + }).unref(); + } } }