diff --git a/desktop/daemon.cc b/desktop/daemon.cc index 1bb209e..e2a52ed 100644 --- a/desktop/daemon.cc +++ b/desktop/daemon.cc @@ -226,10 +226,18 @@ void Daemon::syncPool() { } void Daemon::heartbeat() { - if (m_daemon->state() != QProcess::Running) { + if (m_daemon->state() != QProcess::Running && m_faillock++ < 5) { qWarning() << "Daemon is not running, try restart it."; + m_logs->appendLog(Log(QDateTime::currentDateTime().toString(Qt::ISODate), EventLevel::WARNING, + tr("Daemon is not running, try restart it."), "wsrx::desktop::connector")); launch(); return; + } else if (m_faillock >= 5) { + qWarning() << "Daemon is not running, failed to restart it."; + m_logs->appendLog(Log(QDateTime::currentDateTime().toString(Qt::ISODate), EventLevel::ERROR, + tr("Daemon is not running and retries > 5, failed to restart it."), + "wsrx::desktop::connector")); + return; } auto request = QNetworkRequest(service("heartbeat")); auto reply = m_network->get(request); diff --git a/desktop/daemon.h b/desktop/daemon.h index 27a18f7..c3c53f3 100644 --- a/desktop/daemon.h +++ b/desktop/daemon.h @@ -26,6 +26,7 @@ class Daemon : public QObject { QNetworkAccessManager* m_network; QTimer* m_refreshTimer; QTimer* m_heartbeatTimer; + int m_faillock = 0; void syncPool();