add better logging and prevent LbryFirst from trying to start multiple times
This commit is contained in:
parent
4131165d6a
commit
cadcb53399
1 changed files with 23 additions and 20 deletions
|
@ -89,45 +89,48 @@ const startDaemon = async () => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let isLbryFirstRunning = false;
|
||||||
const startLbryFirst = async () => {
|
const startLbryFirst = async () => {
|
||||||
let isLbryFirstRunning = false;
|
if (isLbryFirstRunning) {
|
||||||
console.log(`LbryFirst: Start LBRY First App`);
|
console.log('LbryFirst already running');
|
||||||
try {
|
return;
|
||||||
await LbryFirst.status();
|
|
||||||
isLbryFirstRunning = true;
|
|
||||||
console.log('LbryFirst: Already running');
|
|
||||||
handleLbryFirstLaunched();
|
|
||||||
} catch (e) {
|
|
||||||
console.log('status fails', e);
|
|
||||||
console.log('Starting LbryFirst');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isLbryFirstRunning) {
|
console.log('LbryFirst: Starting...');
|
||||||
console.log('start process...');
|
|
||||||
|
try {
|
||||||
lbryFirst = new LbryFirstInstance();
|
lbryFirst = new LbryFirstInstance();
|
||||||
lbryFirst.on('exit', () => {
|
lbryFirst.on('exit', e => {
|
||||||
if (!isDev) {
|
if (!isDev) {
|
||||||
lbryFirst = null;
|
lbryFirst = null;
|
||||||
|
isLbryFirstRunning = false;
|
||||||
if (!appState.isQuitting) {
|
if (!appState.isQuitting) {
|
||||||
dialog.showErrorBox(
|
dialog.showErrorBox(
|
||||||
'LbryFirst has Exited',
|
'LbryFirst has Exited',
|
||||||
'The lbryFirst may have encountered an unexpected error, or another lbryFirst instance is already running. \n\n'
|
'The lbryFirst may have encountered an unexpected error, or another lbryFirst instance is already running. \n\n',
|
||||||
|
e
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
app.quit();
|
app.quit();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} catch (e) {
|
||||||
|
console.log('LbryFirst: Failed to create new instance\n\n', e);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
console.log('LbryFirst: Running...');
|
||||||
await lbryFirst.launch();
|
|
||||||
handleLbryFirstLaunched();
|
try {
|
||||||
} catch (e) {
|
await lbryFirst.launch();
|
||||||
console.log('e', e);
|
handleLbryFirstLaunched();
|
||||||
}
|
} catch (e) {
|
||||||
|
isLbryFirstRunning = false;
|
||||||
|
console.log('LbryFirst: Failed to start\n', e);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleLbryFirstLaunched = () => {
|
const handleLbryFirstLaunched = () => {
|
||||||
|
isLbryFirstRunning = true;
|
||||||
rendererWindow.webContents.send('lbry-first-launched');
|
rendererWindow.webContents.send('lbry-first-launched');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue