Merge pull request #36 from Mikunj/fix/multi-instance

Clean up multi instance code.
pull/37/head
sachaaaaa 7 years ago committed by GitHub
commit cb46dd3adb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,5 +1,5 @@
{ {
"storageProfile": "development2", "storageProfile": "development1",
"disableAutoUpdate": true, "disableAutoUpdate": true,
"openDevTools": true "openDevTools": true
} }

@ -56,6 +56,7 @@ const importMode =
process.argv.some(arg => arg === '--import') || config.get('import'); process.argv.some(arg => arg === '--import') || config.get('import');
const development = config.environment === 'development'; const development = config.environment === 'development';
const appInstance = config.util.getEnv('NODE_APP_INSTANCE') || 0;
// We generally want to pull in our own modules after this point, after the user // We generally want to pull in our own modules after this point, after the user
// data directory has been set. // data directory has been set.
@ -96,7 +97,7 @@ function showWindow() {
} }
} }
if (!process.mas && !development) { if (!process.mas) {
console.log('making app single instance'); console.log('making app single instance');
const shouldQuit = app.makeSingleInstance(() => { const shouldQuit = app.makeSingleInstance(() => {
// Someone tried to run a second instance, we should focus our window // Someone tried to run a second instance, we should focus our window
@ -110,7 +111,7 @@ if (!process.mas && !development) {
return true; return true;
}); });
if (shouldQuit) { if (appInstance === 0 && shouldQuit) {
console.log('quitting; we are the second instance'); console.log('quitting; we are the second instance');
app.exit(); app.exit();
} }

@ -13,6 +13,7 @@
"scripts": { "scripts": {
"postinstall": "electron-builder install-app-deps && rimraf node_modules/dtrace-provider", "postinstall": "electron-builder install-app-deps && rimraf node_modules/dtrace-provider",
"start": "electron .", "start": "electron .",
"start-multi": "NODE_APP_INSTANCE=1 electron .",
"grunt": "grunt", "grunt": "grunt",
"icon-gen": "electron-icon-maker --input=images/icon_1024.png --output=./build", "icon-gen": "electron-icon-maker --input=images/icon_1024.png --output=./build",
"generate": "yarn icon-gen && yarn grunt", "generate": "yarn icon-gen && yarn grunt",

Loading…
Cancel
Save