Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/app.pro
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ QT += gui widgets qml quick
CONFIG += c++11 link_pkgconfig welleio
QMAKE_CXXFLAGS += -Wno-unused-parameter
INCLUDEPATH += $${PWD}/includes
LIBS += -lsystemd

include("../config.pri")

Expand Down
20 changes: 19 additions & 1 deletion app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include <QLoggingCategory>
#include <unistd.h>
#include <QElapsedTimer>
#include <QTimer>
#include <systemd/sd-daemon.h>

#include "hudloader.h"

Expand All @@ -40,7 +42,7 @@ int main(int argc, char *argv[])
parser.setApplicationDescription("viktorgino's HeadUnit Desktop");
parser.addHelpOption();
parser.addVersionOption();

QCommandLineOption pluginsOption(QStringList() << "p" << "plugins",
QCoreApplication::translate("main", "Plugins to enable (defaults to all)"),
QCoreApplication::translate("main", "plugins")
Expand Down Expand Up @@ -71,6 +73,22 @@ int main(int argc, char *argv[])
qDebug("%lld ms : Loading theme loader", time.elapsed());
engine.load(QUrl(QStringLiteral("qrc:/loader.qml")));

// If service Type=notify the service is only considered ready once we send this
sd_notify(0, "READY=1");

uint64_t watchdogIntervalUs = 0;
QTimer watchdogTimer;
QObject::connect(&watchdogTimer, &QTimer::timeout, [](){
sd_notify(0, "WATCHDOG=1");
});

// Service WatchdogSec must be set for this to return > 0
if (sd_watchdog_enabled(0, &watchdogIntervalUs) > 0) {
qDebug("Systemd watchdog is enabled with %lu us\n", watchdogIntervalUs);
// Recommended reporting interval is half the watchdog interval
watchdogTimer.start(watchdogIntervalUs / 2000);
}

qDebug("%lld ms : Starting main loop", time.elapsed());
int ret = app.exec();
return ret;
Expand Down