Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DDW-483, DDW-485] Fix missing launcher config error message and prevent orphan processes after app quit #1166

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Changelog
- Implemented extended error messages for transaction fee calculation failures ([PR 1111](https://github.com/input-output-hk/daedalus/pull/1111))
- Implemented forms submission on "Enter" key press ([PR 981](https://github.com/input-output-hk/daedalus/pull/981))
- Implemented Japanese "Terms of use" for the "Testnet" network ([PR 1097](https://github.com/input-output-hk/daedalus/pull/1097))
- Implemented lock-file mechanism which prevents multiple Daedalus instances from running against the same state directory and network ([PR 1113](https://github.com/input-output-hk/daedalus/pull/1113), [PR 1114](https://github.com/input-output-hk/daedalus/pull/1114), [PR 1121](https://github.com/input-output-hk/daedalus/pull/1121))
- Implemented lock-file mechanism which prevents multiple Daedalus instances from running against the same state directory and network ([PR 1113](https://github.com/input-output-hk/daedalus/pull/1113), [PR 1114](https://github.com/input-output-hk/daedalus/pull/1114), [PR 1121](https://github.com/input-output-hk/daedalus/pull/1121), [PR 1166](https://github.com/input-output-hk/daedalus/pull/1166))
- Implemented "New data layer migration" screen ([PR 1096](https://github.com/input-output-hk/daedalus/pull/1096))
- Implemented sending of `cert` and `key` with API requests in order to enable 2-way TLS authentication ([PR 1072](https://github.com/input-output-hk/daedalus/pull/1072))
- Implemented support for Cardano node "structured logging" ([PR 1092](https://github.com/input-output-hk/daedalus/pull/1092), [PR 1122](https://github.com/input-output-hk/daedalus/pull/1122))
Expand Down
21 changes: 18 additions & 3 deletions source/main/config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
// @flow
import path from 'path';
import { app, dialog } from 'electron';
import { readLauncherConfig } from './utils/config';

// Make sure Daedalus is started with required configuration
const { NODE_ENV, LAUNCHER_CONFIG } = process.env;
const isDev = NODE_ENV === 'development';
// Daedalus cannot proceed without a launcher config
if (isDev && !LAUNCHER_CONFIG) throw new Error('Daedalus should be started using nix-shell. Find more details here: https://github.com/input-output-hk/daedalus/blob/develop/README.md\n');
const isProd = NODE_ENV === 'production';
const isStartedByLauncher = !!LAUNCHER_CONFIG;
if (!isStartedByLauncher) {
const isWindows = process.platform === 'win32';
const dialogTitle = 'Daedalus improperly started!';
let dialogMessage;
if (isProd) {
dialogMessage = isWindows ?
'Please start Daedalus using the icon in the Windows start menu or using Daedalus icon on your desktop.' :
'Daedalus was launched without needed configuration. Please start Daedalus using the shortcut provided by the installer.';
} else {
dialogMessage = 'Daedalus should be started using nix-shell. Find more details here: https://github.com/input-output-hk/daedalus/blob/develop/README.md';
}
dialog.showErrorBox(dialogTitle, dialogMessage);
app.exit(1);
}

/**
* The shape of the config params, usually provided to the cadano-node launcher
Expand Down
22 changes: 9 additions & 13 deletions source/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,15 @@ const safeExit = async () => {

app.on('ready', async () => {
// Make sure this is the only Daedalus instance running per cluster before doing anything else
await acquireDaedalusInstanceLock();
try {
await acquireDaedalusInstanceLock();
} catch (e) {
const dialogTitle = 'Daedalus is unable to start!';
const dialogMessage = 'Another Daedalus instance is already running.';
dialog.showErrorBox(dialogTitle, dialogMessage);
app.exit(1);
}

setupLogging();
mainErrorHandler();

Expand All @@ -86,18 +94,6 @@ app.on('ready', async () => {
with CPU: ${JSON.stringify(os.cpus(), null, 2)} with
${JSON.stringify(os.totalmem(), null, 2)} total RAM !!!`);

const isProd = process.env.NODE_ENV === 'production';
const isStartedByLauncher = !!process.env.LAUNCHER_CONFIG;
if (isProd && !isStartedByLauncher) {
const isWindows = process.platform === 'win32';
const dialogTitle = 'Daedalus improperly started!';
const dialogMessage = isWindows ?
'Please start Daedalus using the icon in the Windows start menu or using Daedalus icon on your desktop.' :
'Daedalus was launched without needed configuration. Please start Daedalus using the shortcut provided by the installer.';
dialog.showErrorBox(dialogTitle, dialogMessage);
app.quit();
}

ensureXDGDataIsSet();
makeEnvironmentGlobal(process.env);
await installChromeExtensions(environment.isDev());
Expand Down