diff options
author | Matt Spinler <spinler@us.ibm.com> | 2017-06-14 15:54:12 -0500 |
---|---|---|
committer | Patrick Williams <patrick@stwcx.xyz> | 2017-06-26 01:36:36 +0000 |
commit | a5763ff8f08dd9e3e52cf37d684fbe512658f87e (patch) | |
tree | a3ac2fec25d34355c7e6fc9dd8db14310d8382a0 | |
parent | 0b67b1d558ac6f9c65a3b8b620775097aaa7e99d (diff) | |
download | phosphor-fan-presence-a5763ff8f08dd9e3e52cf37d684fbe512658f87e.tar.gz phosphor-fan-presence-a5763ff8f08dd9e3e52cf37d684fbe512658f87e.zip |
fan-monitor: use sd_notify(READY=1)
After the fans have initialized their Functional inventory
property, send systemd the READY notification. If the service
which runs this application is of type = notify, then systemd
will hold off starting any dependent services until this is sent.
In our case, we want phosphor-fan-control --control to not be
started until this notification is done.
Change-Id: Iec87418ce308aa9ca81a47c20039ade7e8fe66c3
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | monitor/main.cpp | 10 |
2 files changed, 12 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac index 382cb72..4ee8717 100644 --- a/configure.ac +++ b/configure.ac @@ -26,6 +26,8 @@ PKG_CHECK_MODULES([SDBUSPLUS], [sdbusplus], , [AC_MSG_ERROR([The openbmc/sdbusplus package is required])]) PKG_CHECK_MODULES([PHOSPHOR_LOGGING], [phosphor-logging], , [AC_MSG_ERROR([The openbmc/phosphor-logging package is required])]) +PKG_CHECK_MODULES([SYSTEMD], [libsystemd >= 221], , +[AC_MSG_ERROR([Could not find systemd...systemd developement package required])]) # Checks for library functions. LT_INIT # Required for systemd linking diff --git a/monitor/main.cpp b/monitor/main.cpp index 5da6a5b..b9c1d81 100644 --- a/monitor/main.cpp +++ b/monitor/main.cpp @@ -15,6 +15,7 @@ */ #include <phosphor-logging/log.hpp> #include <sdbusplus/bus.hpp> +#include <systemd/sd-daemon.h> #include "event.hpp" #include "fan.hpp" #include "fan_defs.hpp" @@ -48,6 +49,15 @@ int main() fans.emplace_back(std::make_unique<Fan>(bus, eventPtr, fanDef)); } + //Tell systemd we are initialized + r = sd_notify(0, "READY=1"); + if (r < 1) // 0 = nothing sent, < 0 is a failure + { + log<level::ERR>("sd_notify did not send anything", + entry("ERROR=%d", r)); + return -1; + } + r = sd_event_loop(eventPtr.get()); if (r < 0) { |