mirror of
https://github.com/cage-kiosk/cage.git
synced 2026-02-28 01:41:13 -05:00
Add optional feature to notify status to systemd
When enabled, the feature uses libsystemd to notify service manager about the following states: - ready - periodic alive ping (20s) - stopping It allows to use Cage in a systemd unit with following options: Type=notify WatchdogSec=30s
This commit is contained in:
parent
2e593fe5a8
commit
a500d11f0f
7 changed files with 86 additions and 0 deletions
33
notify_systemd.c
Normal file
33
notify_systemd.c
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Cage: A Wayland kiosk.
|
||||
*
|
||||
* Copyright (C) 2018-2020 Jente Hidskes
|
||||
*
|
||||
* See the LICENSE file accompanying this file.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <systemd/sd-daemon.h>
|
||||
|
||||
#include "notify.h"
|
||||
|
||||
void
|
||||
notify_set_state(enum cg_notify_state state)
|
||||
{
|
||||
const char *sd_state;
|
||||
|
||||
switch (state) {
|
||||
case CAGE_READY:
|
||||
sd_state = "READY=1";
|
||||
break;
|
||||
case CAGE_ALIVE:
|
||||
sd_state = "WATCHDOG=1";
|
||||
break;
|
||||
case CAGE_STOPPING:
|
||||
sd_state = "STOPPING=1";
|
||||
break;
|
||||
}
|
||||
|
||||
sd_notify(0, sd_state);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue