Innovenergy_trunk/csharp/Lib/Utils/Watchdog.cs

16 lines
558 B
C#
Raw Normal View History

using System.Runtime.InteropServices;
2023-11-08 14:58:16 +00:00
namespace InnovEnergy.Lib.Utils;
// https://www.freedesktop.org/software/systemd/man/sd_notify.html
2023-08-18 13:57:00 +00:00
public static class Watchdog
{
// "it is generally recommended to ignore the return value of this call. "
2023-09-11 09:32:53 +00:00
// ReSharper disable once StringLiteralTypo
[DllImport("libsystemd.so.0")]
private static extern Int32 sd_notify(Int32 unsetEnvironment, String state);
2023-08-24 08:03:20 +00:00
public static void NotifyReady() => _ = sd_notify(0, "READY=1");
public static void NotifyAlive() => _ = sd_notify(0, "WATCHDOG=1");
}