#systemd #notify #service #status #manager #completion #daemon

sdnotify

Notify service manager about start-up completion and other daemon status changes

5 releases

0.2.0 Jun 23, 2021
0.1.3 Apr 14, 2020
0.1.2 Sep 19, 2019
0.1.1 Sep 19, 2019
0.1.0 Sep 17, 2019

#948 in Unix APIs

MIT license

12KB
216 lines

Notify service manager about start-up completion and other daemon status changes.

Prerequisites

A unit file with service type Notify is required.

Example:

[Unit]
Description=Frobulator
[Service]
Type=notify
ExecStart=/usr/sbin/frobulator
[Install]
WantedBy=multi-user.target

Sync API

    use sdnotify::{SdNotify, Message, Error};

    let notifier = SdNotify::from_env()?;
    notifier.notify_ready()?;

Async API

    use sdnotify::{Message, Error, async_io::SdNotify};
    use tokio::prelude::*;
    use tokio::runtime::current_thread::Runtime;

    let notifier = SdNotify::from_env()?;
    let mut rt = Runtime::new().unwrap();
    rt.block_on(notifier.send(Message::ready())).unwrap();

Dependencies

~0–8.5MB
~68K SLoC