Add systemd notify support

pull/670/head
Simon Stürz 2024-02-16 09:44:36 +01:00
parent cb9607498e
commit bad240025d
4 changed files with 20 additions and 3 deletions

1
debian/control vendored
View File

@ -30,6 +30,7 @@ Build-Depends: debhelper (>= 9.0.0),
libqt5serialport5-dev,
libqt5serialbus5-dev,
influxdb:native,
libsystemd-dev,
Package: nymea

View File

@ -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

View File

@ -60,6 +60,10 @@
#include <QDir>
#include <QCoreApplication>
#ifdef WITH_SYSTEMD
#include <systemd/sd-daemon.h>
#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},

View File

@ -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)