[Bootstrap] Add multi-instance handling
This commit is contained in:
parent
562340a9c5
commit
9674d9e483
2 changed files with 11 additions and 0 deletions
|
@ -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)
|
||||
- `skipStartupUpdateChecks` (bool, default false) - skips startup update checking (Linux-only)
|
||||
- `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:
|
||||
```json
|
||||
|
|
10
src/bootstrap.js
vendored
10
src/bootstrap.js
vendored
|
@ -68,6 +68,8 @@ const startUpdate = () => {
|
|||
});
|
||||
};
|
||||
|
||||
const hasArgvFlag = (flag) => (process.argv || []).slice(1).includes(flag);
|
||||
|
||||
module.exports = () => {
|
||||
// Paths logging
|
||||
log('Paths', `Init! Returns:
|
||||
|
@ -77,6 +79,14 @@ getResources: ${paths.getResources()}
|
|||
getModuleDataPath: ${paths.getModuleDataPath()}
|
||||
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()) {
|
||||
startUpdate();
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue