use sd_notify::NotifyState;
pub struct ServiceReporter {}
impl super::StateReporter for ServiceReporter {
fn starting(&self, _checkpoint: u32, status: &str) {
if let Err(e) = sd_notify::notify(&[NotifyState::Status(status)]) {
log::error!("Unable to report service started state; {e}");
}
}
fn started(&self) {
if let Err(e) = sd_notify::notify(&[NotifyState::Ready]) {
log::error!("Unable to report service started state; {e}");
}
let status = "Running service application";
if let Err(e) = sd_notify::notify(&[NotifyState::Status(status)]) {
log::error!("Unable to report service status; {e}");
}
}
fn stopping(&self, checkpoint: u32, status: &str) {
if checkpoint == 0
&& let Err(e) = sd_notify::notify(&[NotifyState::Stopping])
{
log::error!("Unable to report service stopped state; {e}");
}
if let Err(e) = sd_notify::notify(&[NotifyState::Status(status)]) {
log::error!("Unable to report service stopping state; {e}");
}
}
fn stopped(&self) {
let status = "Service application termination completed";
if let Err(e) = sd_notify::notify(&[NotifyState::Status(status)]) {
log::error!("Unable to report service stopping state; {e}");
}
}
}