Notify service manager about start-up completion and other daemon status changes.
Prerequisites
A unit file with service type Notify
is required.
Example:
[]
=Frobulator
[]
=notify
=/usr/sbin/frobulator
[]
=multi-user.target
Sync API
use sdnotify::{SdNotify, Message, Error};
# fn notify() -> Result<(), Error> {
let notifier = SdNotify::from_env()?;
notifier.notify_ready()?;
# Ok(())
# }
Async API
use sdnotify::{Message, Error, async_io::SdNotify};
use tokio::prelude::*;
use tokio::runtime::current_thread::Runtime;
# fn notify() -> Result<(), Error> {
let notifier = SdNotify::from_env()?;
let mut rt = Runtime::new().unwrap();
rt.block_on(notifier.send(Message::ready())).unwrap();
# Ok(())
# }