[Bootstrap] Add multi-instance handling
This commit is contained in:
parent
562340a9c5
commit
9674d9e483
|
@ -43,6 +43,7 @@ You can configure OpenAsar via `settings.json` (found in your Discord app data /
|
||||||
- `quickstart` (bool, default false) - whether to use Quickstart (experimental)
|
- `quickstart` (bool, default false) - whether to use Quickstart (experimental)
|
||||||
- `skipStartupUpdateChecks` (bool, default false) - skips startup update checking (Linux-only)
|
- `skipStartupUpdateChecks` (bool, default false) - skips startup update checking (Linux-only)
|
||||||
- `autoupdate` (bool, default true) - whether to autoupdate OpenAsar after Discord startup
|
- `autoupdate` (bool, default true) - whether to autoupdate OpenAsar after Discord startup
|
||||||
|
- `multiInstance` (bool, default false) - whether to enable multi-instance
|
||||||
|
|
||||||
An example of a settings.json with OpenAsar config:
|
An example of a settings.json with OpenAsar config:
|
||||||
```json
|
```json
|
||||||
|
|
|
@ -68,6 +68,8 @@ const startUpdate = () => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const hasArgvFlag = (flag) => (process.argv || []).slice(1).includes(flag);
|
||||||
|
|
||||||
module.exports = () => {
|
module.exports = () => {
|
||||||
// Paths logging
|
// Paths logging
|
||||||
log('Paths', `Init! Returns:
|
log('Paths', `Init! Returns:
|
||||||
|
@ -77,6 +79,14 @@ getResources: ${paths.getResources()}
|
||||||
getModuleDataPath: ${paths.getModuleDataPath()}
|
getModuleDataPath: ${paths.getModuleDataPath()}
|
||||||
getInstallPath: ${paths.getInstallPath()}`);
|
getInstallPath: ${paths.getInstallPath()}`);
|
||||||
|
|
||||||
|
const instanceLock = app.requestSingleInstanceLock();
|
||||||
|
const allowMultiInstance = hasArgvFlag('--multi-instance') || oaConfig.multiInstance; // argv flag or config
|
||||||
|
|
||||||
|
if (!instanceLock && !allowMultiInstance) {
|
||||||
|
log('Bootstrap', 'Non-first instance, quitting (multi-instance disabled)');
|
||||||
|
return app.quit();
|
||||||
|
}
|
||||||
|
|
||||||
if (app.isReady()) {
|
if (app.isReady()) {
|
||||||
startUpdate();
|
startUpdate();
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue