mirror of
https://github.com/monero-project/monero-gui.git
synced 2025-02-21 17:20:37 +02:00
pause refresh while starting daemon + startup timeout
This commit is contained in:
parent
df60c8190b
commit
80210376f3
19
main.qml
19
main.qml
@ -380,6 +380,9 @@ ApplicationWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function startDaemon(flags){
|
function startDaemon(flags){
|
||||||
|
// Pause refresh while starting daemon
|
||||||
|
currentWallet.pauseRefresh();
|
||||||
|
|
||||||
appWindow.showProcessingSplash(qsTr("Waiting for daemon to start..."))
|
appWindow.showProcessingSplash(qsTr("Waiting for daemon to start..."))
|
||||||
daemonManager.start(flags, persistentSettings.testnet);
|
daemonManager.start(flags, persistentSettings.testnet);
|
||||||
persistentSettings.daemonFlags = flags
|
persistentSettings.daemonFlags = flags
|
||||||
@ -395,6 +398,8 @@ ApplicationWindow {
|
|||||||
daemonRunning = true;
|
daemonRunning = true;
|
||||||
hideProcessingSplash();
|
hideProcessingSplash();
|
||||||
currentWallet.connected(true);
|
currentWallet.connected(true);
|
||||||
|
// resume refresh
|
||||||
|
currentWallet.startRefresh();
|
||||||
}
|
}
|
||||||
function onDaemonStopped(){
|
function onDaemonStopped(){
|
||||||
console.log("daemon stopped");
|
console.log("daemon stopped");
|
||||||
@ -403,6 +408,19 @@ ApplicationWindow {
|
|||||||
currentWallet.connected(true);
|
currentWallet.connected(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onDaemonStartFailure(){
|
||||||
|
console.log("daemon start failed");
|
||||||
|
hideProcessingSplash();
|
||||||
|
// resume refresh
|
||||||
|
currentWallet.startRefresh();
|
||||||
|
daemonRunning = false;
|
||||||
|
informationPopup.title = qsTr("Daemon failed to start") + translationManager.emptyString;
|
||||||
|
informationPopup.text = qsTr("Please check your wallet and daemon log for errors. You can also try to start %1 manually.").arg((isWindows)? "monerod.exe" : "monerod")
|
||||||
|
informationPopup.icon = StandardIcon.Critical
|
||||||
|
informationPopup.onCloseCallback = null
|
||||||
|
informationPopup.open();
|
||||||
|
}
|
||||||
|
|
||||||
function onWalletNewBlock(blockHeight, targetHeight) {
|
function onWalletNewBlock(blockHeight, targetHeight) {
|
||||||
// Update progress bar
|
// Update progress bar
|
||||||
leftPanel.progressBar.updateProgress(blockHeight,targetHeight);
|
leftPanel.progressBar.updateProgress(blockHeight,targetHeight);
|
||||||
@ -760,6 +778,7 @@ ApplicationWindow {
|
|||||||
walletManager.walletClosed.connect(onWalletClosed);
|
walletManager.walletClosed.connect(onWalletClosed);
|
||||||
|
|
||||||
daemonManager.daemonStarted.connect(onDaemonStarted);
|
daemonManager.daemonStarted.connect(onDaemonStarted);
|
||||||
|
daemonManager.daemonStartFailure.connect(onDaemonStartFailure);
|
||||||
daemonManager.daemonStopped.connect(onDaemonStopped);
|
daemonManager.daemonStopped.connect(onDaemonStopped);
|
||||||
|
|
||||||
if(!walletsFound()) {
|
if(!walletsFound()) {
|
||||||
|
@ -7,6 +7,11 @@
|
|||||||
#include <QtConcurrent/QtConcurrent>
|
#include <QtConcurrent/QtConcurrent>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
|
#include <QTime>
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
static const int DAEMON_START_TIMEOUT_SECONDS = 30;
|
||||||
|
}
|
||||||
|
|
||||||
DaemonManager * DaemonManager::m_instance = nullptr;
|
DaemonManager * DaemonManager::m_instance = nullptr;
|
||||||
QStringList DaemonManager::m_clArgs;
|
QStringList DaemonManager::m_clArgs;
|
||||||
@ -67,8 +72,11 @@ bool DaemonManager::start(const QString &flags, bool testnet)
|
|||||||
// add state changed listener
|
// add state changed listener
|
||||||
connect(m_daemon,SIGNAL(stateChanged(QProcess::ProcessState)),this,SLOT(stateChanged(QProcess::ProcessState)));
|
connect(m_daemon,SIGNAL(stateChanged(QProcess::ProcessState)),this,SLOT(stateChanged(QProcess::ProcessState)));
|
||||||
|
|
||||||
if (!started)
|
if (!started) {
|
||||||
qDebug() << "Daemon start error: " + m_daemon->errorString();
|
qDebug() << "Daemon start error: " + m_daemon->errorString();
|
||||||
|
emit daemonStartFailure();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Start start watcher
|
// Start start watcher
|
||||||
QFuture<bool> future = QtConcurrent::run(this, &DaemonManager::startWatcher, testnet);
|
QFuture<bool> future = QtConcurrent::run(this, &DaemonManager::startWatcher, testnet);
|
||||||
@ -77,14 +85,15 @@ bool DaemonManager::start(const QString &flags, bool testnet)
|
|||||||
this, [this, watcher]() {
|
this, [this, watcher]() {
|
||||||
QFuture<bool> future = watcher->future();
|
QFuture<bool> future = watcher->future();
|
||||||
watcher->deleteLater();
|
watcher->deleteLater();
|
||||||
if(future.result()) {
|
if(future.result())
|
||||||
emit daemonStarted();
|
emit daemonStarted();
|
||||||
}
|
else
|
||||||
|
emit daemonStartFailure();
|
||||||
});
|
});
|
||||||
watcher->setFuture(future);
|
watcher->setFuture(future);
|
||||||
|
|
||||||
|
|
||||||
return started;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DaemonManager::stop(bool testnet)
|
bool DaemonManager::stop(bool testnet)
|
||||||
@ -112,12 +121,17 @@ bool DaemonManager::stop(bool testnet)
|
|||||||
bool DaemonManager::startWatcher(bool testnet) const
|
bool DaemonManager::startWatcher(bool testnet) const
|
||||||
{
|
{
|
||||||
// Check if daemon is started every 2 seconds
|
// Check if daemon is started every 2 seconds
|
||||||
while(true && !m_app_exit) {
|
QTime timer;
|
||||||
|
timer.restart();
|
||||||
|
while(true && !m_app_exit && timer.elapsed() / 1000 < DAEMON_START_TIMEOUT_SECONDS ) {
|
||||||
QThread::sleep(2);
|
QThread::sleep(2);
|
||||||
if(!running(testnet)) {
|
if(!running(testnet)) {
|
||||||
qDebug() << "daemon not running. checking again in 2 seconds.";
|
qDebug() << "daemon not running. checking again in 2 seconds.";
|
||||||
} else
|
} else {
|
||||||
|
qDebug() << "daemon is started. Waiting 5 seconds to let daemon catch up";
|
||||||
|
QThread::sleep(5);
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@ private:
|
|||||||
signals:
|
signals:
|
||||||
void daemonStarted() const;
|
void daemonStarted() const;
|
||||||
void daemonStopped() const;
|
void daemonStopped() const;
|
||||||
|
void daemonStartFailure() const;
|
||||||
void daemonConsoleUpdated(QString message) const;
|
void daemonConsoleUpdated(QString message) const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
Loading…
Reference in New Issue
Block a user