mirror of
https://github.com/everoddandeven/monerod-gui.git
synced 2025-01-03 09:29:36 +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 { openDB, IDBPDatabase } from "idb"
|
||||||
import { PeerInfo, TxPool } from '../../../../common';
|
import { PeerInfo, TxPool } from '../../../../common';
|
||||||
import { MoneroInstallerService } from '../monero-installer/monero-installer.service';
|
import { MoneroInstallerService } from '../monero-installer/monero-installer.service';
|
||||||
|
import { error } from 'console';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
|
@ -337,64 +338,67 @@ export class DaemonService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async startDaemon(customSettings?: DaemonSettings): Promise<void> {
|
public async startDaemon(customSettings?: DaemonSettings): Promise<void> {
|
||||||
await new Promise<void>(async (resolve, reject) => {
|
if (await this.isRunning()) {
|
||||||
if (await this.isRunning()) {
|
console.warn("Daemon already running");
|
||||||
console.warn("Daemon already running");
|
return;
|
||||||
return;
|
}
|
||||||
|
|
||||||
|
this.starting = true;
|
||||||
|
|
||||||
|
console.log("Starting daemon");
|
||||||
|
|
||||||
|
this.settings = customSettings ? customSettings : await this.getSettings();
|
||||||
|
|
||||||
|
if (!this.settings.noSync && !this.settings.syncOnWifi) {
|
||||||
|
const wifiConnected = await this.isWifiConnected();
|
||||||
|
|
||||||
|
if (wifiConnected) {
|
||||||
|
console.log("Disabling sync ...");
|
||||||
|
|
||||||
|
this.settings.noSync = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
this.starting = true;
|
else if (!this.settings.noSync && !this.settings.syncOnWifi) {
|
||||||
|
const wifiConnected = await this.isWifiConnected();
|
||||||
console.log("Starting daemon");
|
|
||||||
|
|
||||||
this.settings = customSettings ? customSettings : await this.getSettings();
|
if (!wifiConnected) {
|
||||||
|
console.log("Enabling sync ...");
|
||||||
if (!this.settings.noSync && !this.settings.syncOnWifi) {
|
|
||||||
const wifiConnected = await this.isWifiConnected();
|
|
||||||
|
|
||||||
if (wifiConnected) {
|
this.settings.noSync = false;
|
||||||
console.log("Disabling sync ...");
|
|
||||||
|
|
||||||
this.settings.noSync = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (!this.settings.noSync && !this.settings.syncOnWifi) {
|
|
||||||
const wifiConnected = await this.isWifiConnected();
|
|
||||||
|
|
||||||
if (!wifiConnected) {
|
|
||||||
console.log("Enabling sync ...");
|
|
||||||
|
|
||||||
this.settings.noSync = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const startPromise = new Promise<void>((resolve, reject) => {
|
||||||
window.electronAPI.onMonerodStarted((event: any, started: boolean) => {
|
window.electronAPI.onMonerodStarted((event: any, started: boolean) => {
|
||||||
console.debug(event);
|
console.debug(event);
|
||||||
|
|
||||||
if (started) {
|
if (started) {
|
||||||
console.log("Daemon started");
|
console.log("Daemon started");
|
||||||
this.onDaemonStatusChanged.emit(true);
|
this.isRunning(true).then((running: boolean) => {
|
||||||
resolve();
|
this.onDaemonStatusChanged.emit(running);
|
||||||
|
this.starting = false;
|
||||||
|
resolve();
|
||||||
|
}).catch((error: any) => {
|
||||||
|
console.error(error);
|
||||||
|
this.onDaemonStatusChanged.emit(false);
|
||||||
|
this.starting = false;
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
console.log("Daemon not started");
|
console.log("Daemon not started");
|
||||||
this.onDaemonStatusChanged.emit(false);
|
this.onDaemonStatusChanged.emit(false);
|
||||||
|
this.starting = false;
|
||||||
reject('Could not start daemon');
|
reject('Could not start daemon');
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
window.electronAPI.startMonerod(this.settings.toCommandOptions());
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.starting = false;
|
window.electronAPI.startMonerod(this.settings.toCommandOptions());
|
||||||
|
await startPromise;
|
||||||
const isRunning: boolean = await this.isRunning(true);
|
|
||||||
|
|
||||||
if (!isRunning) {
|
|
||||||
throw new Error("Daemon started but not running");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async restartDaemon(): Promise<void> {
|
public async restartDaemon(): Promise<void> {
|
||||||
|
|
Loading…
Reference in a new issue