Skip to content

Commit

Permalink
Merge pull request #35 from flokli/sd-notify
Browse files Browse the repository at this point in the history
use sd-notify to signal readyness
  • Loading branch information
geofft committed Oct 18, 2022
2 parents 1d0bf2b + 9fa26c5 commit 706d416
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ crossbeam-channel = "^0.5"
nix = "^0.21.2"
num-derive = "^0.3"
num-traits = "^0.2"
# Hold at 0.3: 0.4 MSRV is too new
sd-notify = "~0.3"
# Indirect dependency, constrained for MSRV
once_cell = "~1.14"

Expand Down
1 change: 1 addition & 0 deletions nsncd.service
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Description=name-service non-caching daemon
[Service]
ExecStart=/usr/lib/nsncd
Restart=always
Type=notify

[Install]
WantedBy=multi-user.target
4 changes: 3 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ use std::time::Duration;

use anyhow::{Context, Result};
use crossbeam_channel as channel;
use sd_notify::NotifyState;
use slog::{debug, error, o, Drain};

mod ffi;
Expand Down Expand Up @@ -83,7 +84,6 @@ fn main() -> Result<()> {
"worker_count" => worker_count,
"handoff_timeout" => ?handoff_timeout,
);

let mut wg = WorkGroup::new();
let tx = spawn_workers(&mut wg, &logger, worker_count);

Expand All @@ -93,6 +93,8 @@ fn main() -> Result<()> {
std::fs::set_permissions(path, std::fs::Permissions::from_mode(0o777))?;
spawn_acceptor(&mut wg, &logger, listener, tx, handoff_timeout);

let _ = sd_notify::notify(true, &[NotifyState::Ready]);

let (result, handles) = wg.run();
if let Err(e) = result {
// if a thread unwound with a panic, just start panicing here. the nss
Expand Down

0 comments on commit 706d416

Please sign in to comment.