Commit 70ebbae1 authored by louiz’'s avatar louiz’

Regularly send a notification for the systemd watchdog

parent a165e592
#include <utils/timed_events.hpp>
#include <utils/scopeguard.hpp>
#include <utils/tolower.hpp>
#include <logger/logger.hpp>
......@@ -273,6 +274,16 @@ void XmppComponent::handle_handshake(const Stanza& stanza)
log_info("Authenticated with the XMPP server");
sd_notify(0, "READY=1");
// Install an event that sends a keepalive to systemd. If biboumi crashes
// or hangs for too long, systemd will restart it.
uint64_t usec;
if (sd_watchdog_enabled(0, &usec) > 0)
std::chrono::microseconds delay(usec);
std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::microseconds(usec / 2)),
[]() { sd_notify(0, "WATCHDOG=1"); }));
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment