mirror of
https://github.com/everoddandeven/monerod-gui.git
synced 2024-10-29 18:37:34 +00:00
Fix start daemon
This commit is contained in:
parent
c95017f4d9
commit
0c91f7222e
1 changed files with 42 additions and 38 deletions
|
@ -80,6 +80,7 @@ import { MethodNotFoundError } from '../../../../common/error/MethodNotFoundErro
|
|||
import { openDB, IDBPDatabase } from "idb"
|
||||
import { PeerInfo, TxPool } from '../../../../common';
|
||||
import { MoneroInstallerService } from '../monero-installer/monero-installer.service';
|
||||
import { error } from 'console';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
|
@ -337,7 +338,6 @@ export class DaemonService {
|
|||
}
|
||||
|
||||
public async startDaemon(customSettings?: DaemonSettings): Promise<void> {
|
||||
await new Promise<void>(async (resolve, reject) => {
|
||||
if (await this.isRunning()) {
|
||||
console.warn("Daemon already running");
|
||||
return;
|
||||
|
@ -368,33 +368,37 @@ export class DaemonService {
|
|||
}
|
||||
}
|
||||
|
||||
const startPromise = new Promise<void>((resolve, reject) => {
|
||||
window.electronAPI.onMonerodStarted((event: any, started: boolean) => {
|
||||
console.debug(event);
|
||||
|
||||
if (started) {
|
||||
console.log("Daemon started");
|
||||
this.onDaemonStatusChanged.emit(true);
|
||||
this.isRunning(true).then((running: boolean) => {
|
||||
this.onDaemonStatusChanged.emit(running);
|
||||
this.starting = false;
|
||||
resolve();
|
||||
}).catch((error: any) => {
|
||||
console.error(error);
|
||||
this.onDaemonStatusChanged.emit(false);
|
||||
this.starting = false;
|
||||
reject(error);
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
else {
|
||||
console.log("Daemon not started");
|
||||
this.onDaemonStatusChanged.emit(false);
|
||||
this.starting = false;
|
||||
reject('Could not start daemon');
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
window.electronAPI.startMonerod(this.settings.toCommandOptions());
|
||||
|
||||
});
|
||||
|
||||
this.starting = false;
|
||||
|
||||
const isRunning: boolean = await this.isRunning(true);
|
||||
|
||||
if (!isRunning) {
|
||||
throw new Error("Daemon started but not running");
|
||||
}
|
||||
window.electronAPI.startMonerod(this.settings.toCommandOptions());
|
||||
await startPromise;
|
||||
}
|
||||
|
||||
public async restartDaemon(): Promise<void> {
|
||||
|
|
Loading…
Reference in a new issue