mirror of
https://github.com/kanidm/kanidm.git
synced 2025-04-30 14:15:05 +02:00
implement notify-reload protocol (#3540)
This commit is contained in:
parent
82a883089f
commit
ad012cd6fd
|
@ -724,14 +724,6 @@ async fn kanidm_main(config: Configuration, opt: KanidmdParser) -> ExitCode {
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
{
|
{
|
||||||
let _ = sd_notify::notify(true, &[sd_notify::NotifyState::Ready]);
|
let _ = sd_notify::notify(true, &[sd_notify::NotifyState::Ready]);
|
||||||
// Undocumented systemd feature - all messages should have a monotonic usec sent
|
|
||||||
// with them. In some cases like "reloading" messages, it is undocumented but
|
|
||||||
// failure to send this message causes the reload to fail.
|
|
||||||
if let Ok(monotonic_usec) = sd_notify::NotifyState::monotonic_usec_now() {
|
|
||||||
let _ = sd_notify::notify(true, &[monotonic_usec]);
|
|
||||||
} else {
|
|
||||||
error!("CRITICAL!!! Unable to access clock monotonic time. SYSTEMD WILL KILL US.");
|
|
||||||
};
|
|
||||||
let _ = sd_notify::notify(
|
let _ = sd_notify::notify(
|
||||||
true,
|
true,
|
||||||
&[sd_notify::NotifyState::Status("Started Kanidm 🦀")],
|
&[sd_notify::NotifyState::Status("Started Kanidm 🦀")],
|
||||||
|
@ -771,16 +763,12 @@ async fn kanidm_main(config: Configuration, opt: KanidmdParser) -> ExitCode {
|
||||||
// systemd has a special reload handler for this.
|
// systemd has a special reload handler for this.
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
{
|
{
|
||||||
let _ = sd_notify::notify(true, &[sd_notify::NotifyState::Reloading]);
|
|
||||||
// CRITICAL - if you do not send a monotonic usec message after a reloading
|
|
||||||
// message, your service WILL BE KILLED.
|
|
||||||
if let Ok(monotonic_usec) = sd_notify::NotifyState::monotonic_usec_now() {
|
if let Ok(monotonic_usec) = sd_notify::NotifyState::monotonic_usec_now() {
|
||||||
let _ =
|
let _ = sd_notify::notify(true, &[sd_notify::NotifyState::Reloading, monotonic_usec]);
|
||||||
sd_notify::notify(true, &[monotonic_usec]);
|
let _ = sd_notify::notify(true, &[sd_notify::NotifyState::Status("Reloading ...")]);
|
||||||
} else {
|
} else {
|
||||||
error!("CRITICAL!!! Unable to access clock monotonic time. SYSTEMD WILL KILL US.");
|
error!("CRITICAL!!! Unable to access clock monotonic time. SYSTEMD WILL KILL US.");
|
||||||
};
|
};
|
||||||
let _ = sd_notify::notify(true, &[sd_notify::NotifyState::Status("Reloading ...")]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sctx.tls_acceptor_reload().await;
|
sctx.tls_acceptor_reload().await;
|
||||||
|
@ -791,14 +779,12 @@ async fn kanidm_main(config: Configuration, opt: KanidmdParser) -> ExitCode {
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
{
|
{
|
||||||
let _ = sd_notify::notify(true, &[sd_notify::NotifyState::Ready]);
|
|
||||||
if let Ok(monotonic_usec) = sd_notify::NotifyState::monotonic_usec_now() {
|
if let Ok(monotonic_usec) = sd_notify::NotifyState::monotonic_usec_now() {
|
||||||
let _ =
|
let _ = sd_notify::notify(true, &[sd_notify::NotifyState::Ready, monotonic_usec]);
|
||||||
sd_notify::notify(true, &[monotonic_usec]);
|
let _ = sd_notify::notify(true, &[sd_notify::NotifyState::Status("Reload Success")]);
|
||||||
} else {
|
} else {
|
||||||
error!("CRITICAL!!! Unable to access clock monotonic time. SYSTEMD WILL KILL US.");
|
error!("CRITICAL!!! Unable to access clock monotonic time. SYSTEMD WILL KILL US.");
|
||||||
};
|
};
|
||||||
let _ = sd_notify::notify(true, &[sd_notify::NotifyState::Status("Reload Success")]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
info!("Reload complete");
|
info!("Reload complete");
|
||||||
|
|
Loading…
Reference in a new issue