#service-manager #notify #systemd #daemon #completion #status #start-up

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

#813 in Unix APIs

Download history 46/week @ 2024-01-13 2/week @ 2024-01-20 21/week @ 2024-02-17 85/week @ 2024-02-24 11/week @ 2024-03-02

117 downloads per month

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–11MB
~77K SLoC