From bad240025dfe2a939d191ca6cb74c5a1b093fc47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20St=C3=BCrz?= Date: Fri, 16 Feb 2024 09:44:36 +0100 Subject: [PATCH] Add systemd notify support --- debian/control | 1 + libnymea-core/libnymea-core.pro | 8 ++++++++ libnymea-core/nymeacore.cpp | 11 +++++++++++ server/server.pro | 3 --- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/debian/control b/debian/control index 3343270e..7d6cc17a 100644 --- a/debian/control +++ b/debian/control @@ -30,6 +30,7 @@ Build-Depends: debhelper (>= 9.0.0), libqt5serialport5-dev, libqt5serialbus5-dev, influxdb:native, + libsystemd-dev, Package: nymea diff --git a/libnymea-core/libnymea-core.pro b/libnymea-core/libnymea-core.pro index 98253acc..2eaa8a59 100644 --- a/libnymea-core/libnymea-core.pro +++ b/libnymea-core/libnymea-core.pro @@ -35,6 +35,14 @@ CONFIG(withoutpython) { CONFIG -= python } +packagesExist(systemd) { + message(Building with systemd support) + PKGCONFIG += systemd + DEFINES += WITH_SYSTEMD +} else { + message(Building without systemd support) +} + packagesExist(Qt5SerialBus) { message("Building with QtSerialBus support.") PKGCONFIG += Qt5SerialBus diff --git a/libnymea-core/nymeacore.cpp b/libnymea-core/nymeacore.cpp index d68962e7..9955ccd0 100644 --- a/libnymea-core/nymeacore.cpp +++ b/libnymea-core/nymeacore.cpp @@ -60,6 +60,10 @@ #include #include +#ifdef WITH_SYSTEMD +#include +#endif + NYMEA_LOGGING_CATEGORY(dcCore, "Core") namespace nymeaserver { @@ -162,11 +166,18 @@ void NymeaCore::init(const QStringList &additionalInterfaces, bool disableLogEng connect(m_thingManager, &ThingManagerImplementation::loaded, this, &NymeaCore::thingManagerLoaded); m_logger->log({"started"}, {{"version", NYMEA_VERSION_STRING}}); +#ifdef WITH_SYSTEMD + sd_notify(0, "READY=1"); +#endif } /*! Destructor of the \l{NymeaCore}. */ NymeaCore::~NymeaCore() { +#ifdef WITH_SYSTEMD + sd_notify(0, "STOPPING=1"); +#endif + qCDebug(dcCore()) << "Shutting down NymeaCore"; m_logger->log({"stopped"}, { {"version", NYMEA_VERSION_STRING}, diff --git a/server/server.pro b/server/server.pro index d6914e66..d394638f 100644 --- a/server/server.pro +++ b/server/server.pro @@ -24,9 +24,6 @@ LIBS += -L$$top_builddir/libnymea/ -lnymea \ LIBS += -Wl,-rpath ../libnymea-core/ } -CONFIG += link_pkgconfig -PKGCONFIG += nymea-zigbee - # Server files include(qtservice/qtservice.pri)