Check for running daemon

This commit is contained in:
Igor Gassmann 2018-01-29 11:14:31 -03:00
parent 0ad04abce5
commit bd46bc18cc

View file

@ -2,6 +2,7 @@
// Module imports
import keytar from 'keytar-prebuild';
import SemVer from 'semver';
import findProcess from 'find-process';
import url from 'url';
import https from 'https';
import { shell, app, ipcMain, dialog } from 'electron';
@ -57,18 +58,22 @@ app.setAsDefaultProtocolClient('lbry');
app.setName('LBRY');
app.on('ready', async () => {
daemon = new Daemon();
daemon.on('exit', () => {
daemon = null;
if (!isQuitting) {
dialog.showErrorBox(
'Daemon has Exited',
'The daemon may have encountered an unexpected error, or another daemon instance is already running.'
);
app.quit();
}
});
daemon.launch();
const processList = await findProcess('name', 'lbrynet-daemon');
const isDaemonRunning = processList.length > 0;
if (!isDaemonRunning) {
daemon = new Daemon();
daemon.on('exit', () => {
daemon = null;
if (!isQuitting) {
dialog.showErrorBox(
'Daemon has Exited',
'The daemon may have encountered an unexpected error, or another daemon instance is already running.'
);
app.quit();
}
});
daemon.launch();
}
if (process.env.NODE_ENV === 'development') {
await installExtensions();
}