fix(daemon): check if old daemon is running in case of relaunch
This commit is contained in:
parent
d9758d6dee
commit
52691b5df2
|
@ -24,7 +24,7 @@ export const withDaemonStatusCheck = <PassedProps: {}>(
|
|||
state = {
|
||||
isRunning: false,
|
||||
progress: 0,
|
||||
message: 'ZEC Wallet Starting',
|
||||
message: 'Zepio Wallet Starting',
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
|
@ -64,7 +64,7 @@ export const withDaemonStatusCheck = <PassedProps: {}>(
|
|||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
const statusMessage = error.message === 'Something went wrong' ? 'ZEC Wallet Starting' : error.message;
|
||||
const statusMessage = error.message === 'Something went wrong' ? 'Zepio Wallet Starting' : error.message;
|
||||
|
||||
const isRpcOff = Math.trunc(error.statusCode / 100) === 5;
|
||||
|
||||
|
|
|
@ -52,7 +52,9 @@ const mapDispatchToProps = (dispatch: Dispatch): MapDispatchToProps => ({
|
|||
updateZcashNetwork: (newNetwork) => {
|
||||
electronStore.set(ZCASH_NETWORK, newNetwork);
|
||||
|
||||
electron.remote.app.relaunch();
|
||||
electron.remote.app.relaunch({
|
||||
args: Array.from(new Set(electron.remote.process.argv.slice(1).concat(['--relaunch']))),
|
||||
});
|
||||
electron.remote.app.quit();
|
||||
},
|
||||
});
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
// @flow
|
||||
import eres from 'eres';
|
||||
import processExists from 'process-exists';
|
||||
|
||||
// eslint-disable-next-line
|
||||
export default (processName: string): Promise<void> => new Promise((resolve) => {
|
||||
const interval = setInterval(async () => {
|
||||
const [, isRunning] = await eres(processExists(processName));
|
||||
|
||||
if (!isRunning) {
|
||||
clearInterval(interval);
|
||||
resolve();
|
||||
}
|
||||
}, 500);
|
||||
});
|
|
@ -12,7 +12,7 @@ import uuid from 'uuid/v4';
|
|||
import findProcess from 'find-process';
|
||||
/* eslint-disable-next-line import/named */
|
||||
import { mainWindow } from '../electron';
|
||||
|
||||
import waitForDaemonClose from './wait-for-daemon-close';
|
||||
import getBinariesPath from './get-binaries-path';
|
||||
import getOsFolder from './get-os-folder';
|
||||
import getDaemonName from './get-daemon-name';
|
||||
|
@ -71,10 +71,16 @@ const runDaemon: () => Promise<?ChildProcess> = () => new Promise(async (resolve
|
|||
return reject(new Error(err));
|
||||
}
|
||||
|
||||
if (!mainWindow.isDestroyed()) mainWindow.webContents.send('zcashd-params-download', 'ZEC Wallet Starting');
|
||||
if (!mainWindow.isDestroyed()) mainWindow.webContents.send('zcashd-params-download', 'Zepio Wallet Starting');
|
||||
log('Fetch Params finished!');
|
||||
store.set('DAEMON_FETCHING_PARAMS', false);
|
||||
|
||||
// In case of --relaunch on argv, we need wait to close the old zcash daemon
|
||||
// a workaround is use a interval to check if there is a old process running
|
||||
if (process.argv.find(arg => arg === '--relaunch')) {
|
||||
await waitForDaemonClose(ZCASHD_PROCESS_NAME);
|
||||
}
|
||||
|
||||
const [, isRunning] = await eres(processExists(ZCASHD_PROCESS_NAME));
|
||||
|
||||
// This will parse and save rpcuser and rpcpassword in the store
|
||||
|
|
Loading…
Reference in New Issue