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 // Module imports
import keytar from 'keytar-prebuild'; import keytar from 'keytar-prebuild';
import SemVer from 'semver'; import SemVer from 'semver';
import findProcess from 'find-process';
import url from 'url'; import url from 'url';
import https from 'https'; import https from 'https';
import { shell, app, ipcMain, dialog } from 'electron'; import { shell, app, ipcMain, dialog } from 'electron';
@ -57,6 +58,9 @@ app.setAsDefaultProtocolClient('lbry');
app.setName('LBRY'); app.setName('LBRY');
app.on('ready', async () => { app.on('ready', async () => {
const processList = await findProcess('name', 'lbrynet-daemon');
const isDaemonRunning = processList.length > 0;
if (!isDaemonRunning) {
daemon = new Daemon(); daemon = new Daemon();
daemon.on('exit', () => { daemon.on('exit', () => {
daemon = null; daemon = null;
@ -69,6 +73,7 @@ app.on('ready', async () => {
} }
}); });
daemon.launch(); daemon.launch();
}
if (process.env.NODE_ENV === 'development') { if (process.env.NODE_ENV === 'development') {
await installExtensions(); await installExtensions();
} }