use service Type=notify

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller
2019-04-25 08:38:26 +00:00
parent 9c351a36c4
commit d98c9a7a38
6 changed files with 16 additions and 2 deletions

View File

@ -67,6 +67,8 @@ fn run() -> Result<(), Error> {
},
)?;
daemon::systemd_notify(daemon::SystemdNotify::Ready)?;
tokio::run(lazy(|| {
let init_result: Result<(), Error> = try_block!({

View File

@ -100,6 +100,8 @@ fn run() -> Result<(), Error> {
},
)?;
daemon::systemd_notify(daemon::SystemdNotify::Ready)?;
tokio::run(lazy(|| {
let init_result: Result<(), Error> = try_block!({

View File

@ -103,6 +103,9 @@ impl Reloader {
}
Ok(ForkResult::Parent { child }) => {
eprintln!("forked off a new server (pid: {})", child);
if let Err(e) = systemd_notify(SystemdNotify::MainPid(child)) {
log::error!("failed to notify systemd about the new main pid: {}", e);
}
Ok(())
}
Err(e) => {
@ -178,8 +181,12 @@ where
crate::tools::request_shutdown(); // make sure we are in shutdown mode
if server::is_reload_request() {
log::info!("daemon reload...");
if let Err(e) = systemd_notify(SystemdNotify::Reloading) {
log::error!("failed to notify systemd about the state change: {}", e);
}
if let Err(e) = reloader.take().unwrap().fork_restart() {
log::error!("error during reload: {}", e);
let _ = systemd_notify(SystemdNotify::Status(format!("error during reload")));
}
} else {
log::info!("daemon shutting down...");